
<!DOCTYPE HTML>
<html lang="zh-hans" >
<head>
    <meta charset="UTF-8">
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>7.6：对话框详解 · 《Flutter实战》</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="baidu-site-verification" content="Y34sAqDKUH"/>
    <meta name="theme-color" content="#ffffff">
    <!--<meta name="description" content="">-->
    <meta name="description" content="《Flutter实战》是Flutter中文网（https://flutterchina.club）开源的电子书，旨在帮助开发者系统化的了解并学习Flutter。">
    <meta name="keywords" content="flutter实战,flutter书籍,flutter电子书,flutter中文网 ">
    <meta name="generator" content="GitBook 3.2.3">
    
    <meta name="author" content="wendux 824783146@qq.com">
    
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/style.css">

    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/search.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-splitter/splitter.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-prism/prism.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-donate/plugin.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-fontsettings/website.css">
    
    
    

    

    
        
    
        
    
        
    
        
    
        
    

    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://pcdn.flutterchina.club/gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="https://pcdn.flutterchina.club/gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../chapter8/" />
    
    
    <link rel="prev" href="futurebuilder_and_streambuilder.html" />
    

    <style>
        .pull-right > i {
            font-size: 25px;
            color: #777 !important;
            cursor: pointer;

        }

        .pull-right > i:hover {
            color: #777 !important;
        }

        body {
            font-size: 15px !important;
        }

        a[href='../todo.html'], a[href='todo.html'] {
            color: #888 !important;
        }

        .copyright {
            text-align: center;
            margin: 80px 16px 8px 16px;
            padding-top: 16px;
            border-top: #eee 1px solid;
            color: grey;
            font-size: .9em;
        }

        .f-links a{
            text-decoration: underline;
            color: dodgerblue !important;
        }

        .f-links a:hover{
            opacity: .8 !important;
        }

        /*.ad {*/
            /*color: white;*/
            /*text-align: center;*/
            /*background: url(https://img.alicdn.com/tfs/TB1Huu7vMmTBuNjy1XbXXaMrVXa-2880-400.png);*/
            /*background-size: cover;*/
            /*cursor: pointer;*/
            /*margin-bottom: 30px;*/
            /*padding: 18px*/
        /*}*/

        /*.ad:hover {*/
            /*opacity: .8;*/
        /*}*/

        .buy-btn {
            text-decoration: none !important;
            padding: 8px 18px;
            border: #268bd2 1px solid !important;
            display: inline-block !important;
            border-radius: 25px;
            color: #268bd2;
            margin-top: 10px;
        }

        .buy-btn:hover {
            transition: all ease 200ms;
            box-shadow: #555 2px 5px 10px;
            background: #eee;
            color: dodgerblue !important;
        }

        .maoyun{
            padding-top: 5px;
        }


    </style>
</head>
<body>
<!--<div id="ad" style="display: none">-->
<!--<div class="ad ad0"-->
<!--onclick="_track('aliyun','https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=8hhi4dts')">-->
<!--<div style="font-size: 1.3em; padding-right: 120px; position: relative; top: 12px">阿里云新春特惠</div>-->
<!--<div style="color:orange; font-size: 13px">限时红包 最高￥<span style="font-size: 40px">1888</span></div>-->
<!--</div>-->
<!--<div class="ad ad1"-->
<!--onclick="_track('aliyun-puhui','https://promotion.aliyun.com/ntms/act/qwbk.html?spm=5176.11533457.1089570.10.74e877e33jtaGy&userCode=8hhi4dts')">-->
<!--<div style="font-size: 1.5em;">阿里云全民云计算-新春特惠</div>-->
<!--<div style="color:orange; font-size: 18px;padding-top: 4px;">普惠上云，云服务器1核1G仅需293元/年</div>-->
<!--</div>-->
<!--</div>-->

<div class="ad"  style="text-align:center; padding-bottom:30px; display: none"><a href="https://item.jd.com/12816296.html" onclick="buy('img')" title='点击购买' target="_blank"><img style="height:250px;box-shadow: #aaa 5px 5px 10px;" src="https://pcdn.flutterchina.club/imgs/book.png"/></a>  <br/> <a class="buy-btn" onclick="buy('img')" href="https://item.jd.com/12816296.html" title='点击购买' target="_blank"> 购买实体书 </a></div>


<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://flutterchina.club" target="_blank" class="custom-link"><div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div></a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../intro.html">
            
                <a href="../intro.html">
            
                    
                    前言
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">入门篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../chapter1/">
            
                <a href="../chapter1/">
            
                    
                    第一章：起步
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="../chapter1/mobile_development_intro.html">
            
                <a href="../chapter1/mobile_development_intro.html">
            
                    
                    1.1：移动开发技术简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="../chapter1/flutter_intro.html">
            
                <a href="../chapter1/flutter_intro.html">
            
                    
                    1.2：初识Flutter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="../chapter1/install_flutter.html">
            
                <a href="../chapter1/install_flutter.html">
            
                    
                    1.3：搭建Flutter开发环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="../chapter1/dart.html">
            
                <a href="../chapter1/dart.html">
            
                    
                    1.4：Dart语言简介
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../chapter2/">
            
                <a href="../chapter2/">
            
                    
                    第二章：第一个Flutter应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="../chapter2/first_flutter_app.html">
            
                <a href="../chapter2/first_flutter_app.html">
            
                    
                    2.1：计数器示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.2" data-path="../chapter2/flutter_router.html">
            
                <a href="../chapter2/flutter_router.html">
            
                    
                    2.2：路由管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3" data-path="../chapter2/flutter_package_mgr.html">
            
                <a href="../chapter2/flutter_package_mgr.html">
            
                    
                    2.3：包管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.4" data-path="../chapter2/flutter_assets_mgr.html">
            
                <a href="../chapter2/flutter_assets_mgr.html">
            
                    
                    2.4：资源管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5" data-path="../chapter2/flutter_app_debug.html">
            
                <a href="../chapter2/flutter_app_debug.html">
            
                    
                    2.5：调试Flutter APP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6" data-path="../chapter2/thread_model_and_error_report.html">
            
                <a href="../chapter2/thread_model_and_error_report.html">
            
                    
                    2.6：Dart线程模型及异常捕获
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../chapter3/">
            
                <a href="../chapter3/">
            
                    
                    第三章：基础组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="../chapter3/flutter_widget_intro.html">
            
                <a href="../chapter3/flutter_widget_intro.html">
            
                    
                    3.1：Widget简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="../chapter3/state_manage.html">
            
                <a href="../chapter3/state_manage.html">
            
                    
                    3.2：状态管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="../chapter3/text.html">
            
                <a href="../chapter3/text.html">
            
                    
                    3.3：文本、字体样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.4" data-path="../chapter3/buttons.html">
            
                <a href="../chapter3/buttons.html">
            
                    
                    3.4：按钮
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.5" data-path="../chapter3/img_and_icon.html">
            
                <a href="../chapter3/img_and_icon.html">
            
                    
                    3.5：图片和Icon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.6" data-path="../chapter3/radio_and_checkbox.html">
            
                <a href="../chapter3/radio_and_checkbox.html">
            
                    
                    3.6：单选框和复选框
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.7" data-path="../chapter3/input_and_form.html">
            
                <a href="../chapter3/input_and_form.html">
            
                    
                    3.7：输入框和表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.8" data-path="../chapter3/progress.html">
            
                <a href="../chapter3/progress.html">
            
                    
                    3.8：进度指示器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../chapter4/">
            
                <a href="../chapter4/">
            
                    
                    第四章：布局类组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="../chapter4/intro.html">
            
                <a href="../chapter4/intro.html">
            
                    
                    4.1：布局类组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="../chapter4/row_and_column.html">
            
                <a href="../chapter4/row_and_column.html">
            
                    
                    4.2：线性布局（Row、Column）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.3" data-path="../chapter4/flex.html">
            
                <a href="../chapter4/flex.html">
            
                    
                    4.3：弹性布局（Flex）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.4" data-path="../chapter4/wrap_and_flow.html">
            
                <a href="../chapter4/wrap_and_flow.html">
            
                    
                    4.4：流式布局（Wrap、Flow）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.5" data-path="../chapter4/stack.html">
            
                <a href="../chapter4/stack.html">
            
                    
                    4.5：层叠布局（Stack、Positioned）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.6" data-path="../chapter4/alignment.html">
            
                <a href="../chapter4/alignment.html">
            
                    
                    4.6：对齐与相对定位（Align）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../chapter5/">
            
                <a href="../chapter5/">
            
                    
                    第五章：容器类组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="../chapter5/padding.html">
            
                <a href="../chapter5/padding.html">
            
                    
                    5.1：填充（Padding）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.2" data-path="../chapter5/constrainedbox_and_sizebox.html">
            
                <a href="../chapter5/constrainedbox_and_sizebox.html">
            
                    
                    5.2：尺寸限制类容器（ConstrainedBox等）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.3" data-path="../chapter5/decoratedbox.html">
            
                <a href="../chapter5/decoratedbox.html">
            
                    
                    5.3：装饰容器（DecoratedBox）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.4" data-path="../chapter5/transform.html">
            
                <a href="../chapter5/transform.html">
            
                    
                    5.4：变换（Transform）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.5" data-path="../chapter5/container.html">
            
                <a href="../chapter5/container.html">
            
                    
                    5.5：Container容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.6" data-path="../chapter5/material_scaffold.html">
            
                <a href="../chapter5/material_scaffold.html">
            
                    
                    5.6：Scaffold、TabBar、底部导航
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.7" data-path="../chapter5/clip.html">
            
                <a href="../chapter5/clip.html">
            
                    
                    5.7：剪裁（Clip）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../chapter6/">
            
                <a href="../chapter6/">
            
                    
                    第六章：可滚动组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.6.1" data-path="../chapter6/intro.html">
            
                <a href="../chapter6/intro.html">
            
                    
                    6.1：可滚动组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.2" data-path="../chapter6/single_child_scrollview.html">
            
                <a href="../chapter6/single_child_scrollview.html">
            
                    
                    6.2：SingleChildScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.3" data-path="../chapter6/listview.html">
            
                <a href="../chapter6/listview.html">
            
                    
                    6.3：ListView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.4" data-path="../chapter6/gridview.html">
            
                <a href="../chapter6/gridview.html">
            
                    
                    6.4：GridView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.5" data-path="../chapter6/custom_scrollview.html">
            
                <a href="../chapter6/custom_scrollview.html">
            
                    
                    6.5：CustomScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.6" data-path="../chapter6/scroll_controller.html">
            
                <a href="../chapter6/scroll_controller.html">
            
                    
                    6.6：滚动监听及控制（ScrollController）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="./">
            
                <a href="./">
            
                    
                    第七章：功能型组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.7.1" data-path="willpopscope.html">
            
                <a href="willpopscope.html">
            
                    
                    7.1：导航返回拦截（WillPopScope）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.2" data-path="inherited_widget.html">
            
                <a href="inherited_widget.html">
            
                    
                    7.2：数据共享（InheritedWidget）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.3" data-path="provider.html">
            
                <a href="provider.html">
            
                    
                    7.3： 跨组件状态共享（Provider）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.4" data-path="theme.html">
            
                <a href="theme.html">
            
                    
                    7.4：颜色和主题（Theme）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.5" data-path="futurebuilder_and_streambuilder.html">
            
                <a href="futurebuilder_and_streambuilder.html">
            
                    
                    7.5：异步UI更新（FutureBuilder、StreamBuilder）
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.7.6" data-path="dailog.html">
            
                <a href="dailog.html">
            
                    
                    7.6：对话框详解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">进阶篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../chapter8/">
            
                <a href="../chapter8/">
            
                    
                    第八章：事件处理与通知
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../chapter8/listener.html">
            
                <a href="../chapter8/listener.html">
            
                    
                    8.1：原始指针事件处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../chapter8/gesture.html">
            
                <a href="../chapter8/gesture.html">
            
                    
                    8.2：手势识别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../chapter8/eventbus.html">
            
                <a href="../chapter8/eventbus.html">
            
                    
                    8.3：全局事件总线
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.4" data-path="../chapter8/notification.html">
            
                <a href="../chapter8/notification.html">
            
                    
                    8.4：通知(Notification)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../chapter9/">
            
                <a href="../chapter9/">
            
                    
                    第九章：动画
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.2.1" data-path="../chapter9/intro.html">
            
                <a href="../chapter9/intro.html">
            
                    
                    9.1：Flutter动画简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.2" data-path="../chapter9/animation_structure.html">
            
                <a href="../chapter9/animation_structure.html">
            
                    
                    9.2：动画结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.3" data-path="../chapter9/route_transition.html">
            
                <a href="../chapter9/route_transition.html">
            
                    
                    9.3：自定义路由过渡动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.4" data-path="../chapter9/hero.html">
            
                <a href="../chapter9/hero.html">
            
                    
                    9.4：Hero动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.5" data-path="../chapter9/stagger_animation.html">
            
                <a href="../chapter9/stagger_animation.html">
            
                    
                    9.5：交织动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.6" data-path="../chapter9/animated_switcher.html">
            
                <a href="../chapter9/animated_switcher.html">
            
                    
                    9.6：通用“动画切换”组件（AnimatedSwitcher）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.7" data-path="../chapter9/animated_widgets.html">
            
                <a href="../chapter9/animated_widgets.html">
            
                    
                    9.7：动画过渡组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../chapter10/">
            
                <a href="../chapter10/">
            
                    
                    第十章：自定义组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="../chapter10/intro.html">
            
                <a href="../chapter10/intro.html">
            
                    
                    10.1：自定义组件方法简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.2" data-path="../chapter10/combine.html">
            
                <a href="../chapter10/combine.html">
            
                    
                    10.2：组合现有组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.3" data-path="../chapter10/turn_box.html">
            
                <a href="../chapter10/turn_box.html">
            
                    
                    10.3：组合实例：TurnBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.4" data-path="../chapter10/custom_paint.html">
            
                <a href="../chapter10/custom_paint.html">
            
                    
                    10.4：自绘组件（CustomPaint与Canvas）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.5" data-path="../chapter10/gradient_circular_progress_demo.html">
            
                <a href="../chapter10/gradient_circular_progress_demo.html">
            
                    
                    10.5：自绘实例：圆形渐变进度条(自绘)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../chapter11/">
            
                <a href="../chapter11/">
            
                    
                    第十一章：文件操作与网络请求
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.1" data-path="../chapter11/file_operation.html">
            
                <a href="../chapter11/file_operation.html">
            
                    
                    11.1：文件操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.2" data-path="../chapter11/http.html">
            
                <a href="../chapter11/http.html">
            
                    
                    11.2：Http请求-HttpClient
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.3" data-path="../chapter11/dio.html">
            
                <a href="../chapter11/dio.html">
            
                    
                    11.3：Http请求-Dio package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.4" data-path="../chapter11/download_with_chunks.html">
            
                <a href="../chapter11/download_with_chunks.html">
            
                    
                    11.4：实例：Http分块下载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.5" data-path="../chapter11/websocket.html">
            
                <a href="../chapter11/websocket.html">
            
                    
                    11.5：WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.6" data-path="../chapter11/socket.html">
            
                <a href="../chapter11/socket.html">
            
                    
                    11.6：使用Socket API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.7" data-path="../chapter11/json_model.html">
            
                <a href="../chapter11/json_model.html">
            
                    
                    11.7：Json转Dart Model类
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../chapter12/">
            
                <a href="../chapter12/">
            
                    
                    第十二章：包与插件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.5.1" data-path="../chapter12/develop_package.html">
            
                <a href="../chapter12/develop_package.html">
            
                    
                    12.1：开发package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.2" data-path="../chapter12/platform-channel.html">
            
                <a href="../chapter12/platform-channel.html">
            
                    
                    12.2：平台通道简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.3" data-path="../chapter12/develop_plugin.html">
            
                <a href="../chapter12/develop_plugin.html">
            
                    
                    12.3：开发Flutter插件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.4" data-path="../chapter12/android_implement.html">
            
                <a href="../chapter12/android_implement.html">
            
                    
                    12.4：插件开发：实现Android端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.5" data-path="../chapter12/ios_implement.html">
            
                <a href="../chapter12/ios_implement.html">
            
                    
                    12.5：插件开发：实现IOS端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.6" data-path="../chapter12/texture_platformview.html">
            
                <a href="../chapter12/texture_platformview.html">
            
                    
                    12.6：Texture和PlatformView
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../chapter13/">
            
                <a href="../chapter13/">
            
                    
                    第十三章：国际化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.6.1" data-path="../chapter13/multi_languages_support.html">
            
                <a href="../chapter13/multi_languages_support.html">
            
                    
                    13.1：让App支持多语言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.2" data-path="../chapter13/locallization_implement.html">
            
                <a href="../chapter13/locallization_implement.html">
            
                    
                    13.2：实现Localizations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.3" data-path="../chapter13/intl.html">
            
                <a href="../chapter13/intl.html">
            
                    
                    13.3：使用Intl包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.4" data-path="../chapter13/faq.html">
            
                <a href="../chapter13/faq.html">
            
                    
                    13.4：国际化常见问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../chapter14/">
            
                <a href="../chapter14/">
            
                    
                    第十四章：Flutter核心原理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.7.1" data-path="../chapter14/flutter_ui_system.html">
            
                <a href="../chapter14/flutter_ui_system.html">
            
                    
                    14.1：Flutter UI系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.2" data-path="../chapter14/element_buildcontext.html">
            
                <a href="../chapter14/element_buildcontext.html">
            
                    
                    14.2：Element和BuildContext
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.3" data-path="../chapter14/render_object.html">
            
                <a href="../chapter14/render_object.html">
            
                    
                    14.3：RenderObject与RenderBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.4" data-path="../chapter14/flutter_app_startup.html">
            
                <a href="../chapter14/flutter_app_startup.html">
            
                    
                    14.4：Flutter从启动到显示
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.5" data-path="../chapter14/image_and_cache.html">
            
                <a href="../chapter14/image_and_cache.html">
            
                    
                    14.5：Flutter图片加载与缓存
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">实例篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../chapter15/intro.html">
            
                <a href="../chapter15/intro.html">
            
                    
                    第十五章：一个完整的Flutter应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../chapter15/intro.html">
            
                <a href="../chapter15/intro.html">
            
                    
                    15.1：应用简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../chapter15/code_structure.html">
            
                <a href="../chapter15/code_structure.html">
            
                    
                    15.2：APP代码结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="../chapter15/models.html">
            
                <a href="../chapter15/models.html">
            
                    
                    15.3：Model类定义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="../chapter15/globals.html">
            
                <a href="../chapter15/globals.html">
            
                    
                    15.4：全局变量及共享状态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="../chapter15/network.html">
            
                <a href="../chapter15/network.html">
            
                    
                    15.5：网络请求封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.6" data-path="../chapter15/entry.html">
            
                <a href="../chapter15/entry.html">
            
                    
                    15.6：App入口及首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.7" data-path="../chapter15/login_page.html">
            
                <a href="../chapter15/login_page.html">
            
                    
                    15.7：登录页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.8" data-path="../chapter15/language_and_theme_setting.html">
            
                <a href="../chapter15/language_and_theme_setting.html">
            
                    
                    15.8：多语言和多主题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="https://pcdn.flutterchina.club/gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    
    <a class="btn pull-right" aria-label="GitHub">
        <i class="fa fa-edit" title="编辑本文"></i>
    </a>
    <a class="btn pull-right" aria-label="GitHub" href="https://github.com/flutterchina/flutter-in-action">
        <i class="fa fa-github" title="查看本书开源项目"></i>
    </a>
    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >7.6：对话框详解</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="76-&#x5BF9;&#x8BDD;&#x6846;&#x8BE6;&#x89E3;">7.6 &#x5BF9;&#x8BDD;&#x6846;&#x8BE6;&#x89E3;</h1>
<p>&#x672C;&#x8282;&#x5C06;&#x8BE6;&#x7EC6;&#x4ECB;&#x7ECD;&#x4E00;&#x4E0B;Flutter&#x4E2D;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x4F7F;&#x7528;&#x65B9;&#x5F0F;&#x3001;&#x5B9E;&#x73B0;&#x539F;&#x7406;&#x3001;&#x6837;&#x5F0F;&#x5B9A;&#x5236;&#x53CA;&#x72B6;&#x6001;&#x7BA1;&#x7406;&#x3002;</p>
<h2 id="761-&#x4F7F;&#x7528;&#x5BF9;&#x8BDD;&#x6846;">7.6.1 &#x4F7F;&#x7528;&#x5BF9;&#x8BDD;&#x6846;</h2>
<p>&#x5BF9;&#x8BDD;&#x6846;&#x672C;&#x8D28;&#x4E0A;&#x4E5F;&#x662F;UI&#x5E03;&#x5C40;&#xFF0C;&#x901A;&#x5E38;&#x4E00;&#x4E2A;&#x5BF9;&#x8BDD;&#x6846;&#x4F1A;&#x5305;&#x542B;&#x6807;&#x9898;&#x3001;&#x5185;&#x5BB9;&#xFF0C;&#x4EE5;&#x53CA;&#x4E00;&#x4E9B;&#x64CD;&#x4F5C;&#x6309;&#x94AE;&#xFF0C;&#x4E3A;&#x6B64;&#xFF0C;Material&#x5E93;&#x4E2D;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E9B;&#x73B0;&#x6210;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#x7EC4;&#x4EF6;&#x6765;&#x7528;&#x4E8E;&#x5FEB;&#x901F;&#x7684;&#x6784;&#x5EFA;&#x51FA;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#x3002;</p>
<h3 id="alertdialog">AlertDialog</h3>
<p>&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x4E3B;&#x8981;&#x4ECB;&#x7ECD;&#x4E00;&#x4E0B;Material&#x5E93;&#x4E2D;&#x7684;<code>AlertDialog</code>&#x7EC4;&#x4EF6;&#xFF0C;&#x5B83;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x5B9A;&#x4E49;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">const</span> <span class="token function">AlertDialog</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  Key key<span class="token punctuation">,</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>title<span class="token punctuation">,</span> <span class="token comment">//&#x5BF9;&#x8BDD;&#x6846;&#x6807;&#x9898;&#x7EC4;&#x4EF6;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>titlePadding<span class="token punctuation">,</span> <span class="token comment">// &#x6807;&#x9898;&#x586B;&#x5145;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>titleTextStyle<span class="token punctuation">,</span> <span class="token comment">//&#x6807;&#x9898;&#x6587;&#x672C;&#x6837;&#x5F0F;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>content<span class="token punctuation">,</span> <span class="token comment">// &#x5BF9;&#x8BDD;&#x6846;&#x5185;&#x5BB9;&#x7EC4;&#x4EF6;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>contentPadding <span class="token operator">=</span> <span class="token keyword">const</span> EdgeInsets<span class="token punctuation">.</span><span class="token function">fromLTRB</span><span class="token punctuation">(</span><span class="token number">24.0</span><span class="token punctuation">,</span> <span class="token number">20.0</span><span class="token punctuation">,</span> <span class="token number">24.0</span><span class="token punctuation">,</span> <span class="token number">24.0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token comment">//&#x5185;&#x5BB9;&#x7684;&#x586B;&#x5145;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>contentTextStyle<span class="token punctuation">,</span><span class="token comment">// &#x5185;&#x5BB9;&#x6587;&#x672C;&#x6837;&#x5F0F;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>actions<span class="token punctuation">,</span> <span class="token comment">// &#x5BF9;&#x8BDD;&#x6846;&#x64CD;&#x4F5C;&#x6309;&#x94AE;&#x7EC4;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>backgroundColor<span class="token punctuation">,</span> <span class="token comment">// &#x5BF9;&#x8BDD;&#x6846;&#x80CC;&#x666F;&#x8272;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>elevation<span class="token punctuation">,</span><span class="token comment">// &#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x9634;&#x5F71;</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>semanticLabel<span class="token punctuation">,</span> <span class="token comment">//&#x5BF9;&#x8BDD;&#x6846;&#x8BED;&#x4E49;&#x5316;&#x6807;&#x7B7E;(&#x7528;&#x4E8E;&#x8BFB;&#x5C4F;&#x8F6F;&#x4EF6;)</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>shape<span class="token punctuation">,</span> <span class="token comment">// &#x5BF9;&#x8BDD;&#x6846;&#x5916;&#x5F62;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre>
<p>&#x53C2;&#x6570;&#x90FD;&#x6BD4;&#x8F83;&#x7B80;&#x5355;&#xFF0C;&#x4E0D;&#x5728;&#x8D58;&#x8FF0;&#x3002;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x770B;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x5047;&#x5982;&#x6211;&#x4EEC;&#x8981;&#x5728;&#x5220;&#x9664;&#x6587;&#x4EF6;&#x65F6;&#x5F39;&#x51FA;&#x4E00;&#x4E2A;&#x786E;&#x8BA4;&#x5BF9;&#x8BDD;&#x6846;&#xFF0C;&#x8BE5;&#x5BF9;&#x8BDD;&#x6846;&#x5982;&#x56FE;7-10&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-10.png" alt="&#x56FE;7-10"></p>
<p>&#x8BE5;&#x5BF9;&#x8BDD;&#x6846;&#x6837;&#x5F0F;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token function">AlertDialog</span><span class="token punctuation">(</span>
  title<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x63D0;&#x793A;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  content<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x60A8;&#x786E;&#x5B9A;&#x8981;&#x5220;&#x9664;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x5417;?&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  actions<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
    <span class="token function">FlatButton</span><span class="token punctuation">(</span>
      child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x53D6;&#x6D88;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token comment">//&#x5173;&#x95ED;&#x5BF9;&#x8BDD;&#x6846;</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">FlatButton</span><span class="token punctuation">(</span>
      child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5220;&#x9664;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// ... &#x6267;&#x884C;&#x5220;&#x9664;&#x64CD;&#x4F5C;</span>
        Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//&#x5173;&#x95ED;&#x5BF9;&#x8BDD;&#x6846;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x5B9E;&#x73B0;&#x4EE3;&#x7801;&#x5F88;&#x7B80;&#x5355;&#xFF0C;&#x4E0D;&#x5728;&#x8D58;&#x8FF0;&#x3002;&#x552F;&#x4E00;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#x6211;&#x4EEC;&#x662F;&#x901A;&#x8FC7;<code>Navigator.of(context).pop(&#x2026;)</code>&#x65B9;&#x6CD5;&#x6765;&#x5173;&#x95ED;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#xFF0C;&#x8FD9;&#x548C;&#x8DEF;&#x7531;&#x8FD4;&#x56DE;&#x7684;&#x65B9;&#x5F0F;&#x662F;&#x4E00;&#x81F4;&#x7684;&#xFF0C;&#x5E76;&#x4E14;&#x90FD;&#x53EF;&#x4EE5;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7ED3;&#x679C;&#x6570;&#x636E;&#x3002;&#x73B0;&#x5728;&#xFF0C;&#x5BF9;&#x8BDD;&#x6846;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x6784;&#x5EFA;&#x597D;&#x4E86;&#xFF0C;&#x90A3;&#x4E48;&#x5982;&#x4F55;&#x5C06;&#x5B83;&#x5F39;&#x51FA;&#x6765;&#x5462;&#xFF1F;&#x8FD8;&#x6709;&#x5BF9;&#x8BDD;&#x6846;&#x8FD4;&#x56DE;&#x7684;&#x6570;&#x636E;&#x5E94;&#x5982;&#x4F55;&#x88AB;&#x63A5;&#x6536;&#x5462;&#xFF1F;&#x8FD9;&#x4E9B;&#x95EE;&#x9898;&#x7684;&#x7B54;&#x6848;&#x90FD;&#x5728;<code>showDialog()</code>&#x65B9;&#x6CD5;&#x4E2D;&#x3002;</p>
<p><code>showDialog()</code>&#x662F;Material&#x7EC4;&#x4EF6;&#x5E93;&#x63D0;&#x4F9B;&#x7684;&#x4E00;&#x4E2A;&#x7528;&#x4E8E;&#x5F39;&#x51FA;Material&#x98CE;&#x683C;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x7B7E;&#x540D;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Future<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span> showDialog<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token metadata symbol">@required</span> BuildContext context<span class="token punctuation">,</span>
  bool barrierDismissible <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">,</span> <span class="token comment">//&#x70B9;&#x51FB;&#x5BF9;&#x8BDD;&#x6846;barrier(&#x906E;&#x7F69;)&#x65F6;&#x662F;&#x5426;&#x5173;&#x95ED;&#x5B83;</span>
  WidgetBuilder builder<span class="token punctuation">,</span> <span class="token comment">// &#x5BF9;&#x8BDD;&#x6846;UI&#x7684;builder</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre>
<p>&#x8BE5;&#x65B9;&#x6CD5;&#x53EA;&#x6709;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x542B;&#x4E49;&#x89C1;&#x6CE8;&#x91CA;&#x3002;&#x8BE5;&#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;<code>Future</code>&#xFF0C;&#x5B83;&#x6B63;&#x662F;&#x7528;&#x4E8E;&#x63A5;&#x6536;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#xFF1A;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x662F;&#x901A;&#x8FC7;&#x70B9;&#x51FB;&#x5BF9;&#x8BDD;&#x6846;&#x906E;&#x7F69;&#x5173;&#x95ED;&#x7684;&#xFF0C;&#x5219;<code>Future</code>&#x7684;&#x503C;&#x4E3A;<code>null</code>&#xFF0C;&#x5426;&#x5219;&#x4E3A;&#x6211;&#x4EEC;&#x901A;&#x8FC7;<code>Navigator.of(context).pop(result)</code>&#x8FD4;&#x56DE;&#x7684;result&#x503C;&#xFF0C;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x770B;&#x4E00;&#x4E0B;&#x6574;&#x4E2A;&#x793A;&#x4F8B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token comment">//&#x70B9;&#x51FB;&#x8BE5;&#x6309;&#x94AE;&#x540E;&#x5F39;&#x51FA;&#x5BF9;&#x8BDD;&#x6846;</span>
<span class="token function">RaisedButton</span><span class="token punctuation">(</span>
  child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5BF9;&#x8BDD;&#x6846;1&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
    <span class="token comment">//&#x5F39;&#x51FA;&#x5BF9;&#x8BDD;&#x6846;&#x5E76;&#x7B49;&#x5F85;&#x5176;&#x5173;&#x95ED;</span>
    bool delete <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">showDeleteConfirmDialog1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>delete <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x53D6;&#x6D88;&#x5220;&#x9664;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5DF2;&#x786E;&#x8BA4;&#x5220;&#x9664;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token comment">//... &#x5220;&#x9664;&#x6587;&#x4EF6;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">,</span>

<span class="token comment">// &#x5F39;&#x51FA;&#x5BF9;&#x8BDD;&#x6846;</span>
Future<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span> <span class="token function">showDeleteConfirmDialog1</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> showDialog<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span><span class="token punctuation">(</span>
    context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
    builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token function">AlertDialog</span><span class="token punctuation">(</span>
        title<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x63D0;&#x793A;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
        content<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x60A8;&#x786E;&#x5B9A;&#x8981;&#x5220;&#x9664;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x5417;?&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
        actions<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
          <span class="token function">FlatButton</span><span class="token punctuation">(</span>
            child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x53D6;&#x6D88;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token comment">// &#x5173;&#x95ED;&#x5BF9;&#x8BDD;&#x6846;</span>
          <span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token function">FlatButton</span><span class="token punctuation">(</span>
            child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5220;&#x9664;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
              <span class="token comment">//&#x5173;&#x95ED;&#x5BF9;&#x8BDD;&#x6846;&#x5E76;&#x8FD4;&#x56DE;true</span>
              Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span><span class="token punctuation">,</span>
        <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x793A;&#x4F8B;&#x8FD0;&#x884C;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x70B9;&#x51FB;&#x5BF9;&#x8BDD;&#x6846;&#x201C;&#x53D6;&#x6D88;&#x201D;&#x6309;&#x94AE;&#x6216;&#x906E;&#x7F69;&#xFF0C;&#x63A7;&#x5236;&#x53F0;&#x5C31;&#x4F1A;&#x8F93;&#x51FA;&quot;&#x53D6;&#x6D88;&#x5220;&#x9664;&quot;&#xFF0C;&#x5982;&#x679C;&#x70B9;&#x51FB;&#x201C;&#x5220;&#x9664;&#x201D;&#x6309;&#x94AE;&#xFF0C;&#x63A7;&#x5236;&#x53F0;&#x5C31;&#x4F1A;&#x8F93;&#x51FA;&quot;&#x5DF2;&#x786E;&#x8BA4;&#x5220;&#x9664;&quot;&#x3002;</p>
<blockquote>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x5982;&#x679C;<code>AlertDialog</code>&#x7684;&#x5185;&#x5BB9;&#x8FC7;&#x957F;&#xFF0C;&#x5185;&#x5BB9;&#x5C06;&#x4F1A;&#x6EA2;&#x51FA;&#xFF0C;&#x8FD9;&#x5728;&#x5F88;&#x591A;&#x65F6;&#x5019;&#x53EF;&#x80FD;&#x4E0D;&#x662F;&#x6211;&#x4EEC;&#x671F;&#x671B;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x5982;&#x679C;&#x5BF9;&#x8BDD;&#x6846;&#x5185;&#x5BB9;&#x8FC7;&#x957F;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x7528;<code>SingleChildScrollView</code>&#x5C06;&#x5185;&#x5BB9;&#x5305;&#x88F9;&#x8D77;&#x6765;&#x3002;</p>
</blockquote>
<h3 id="simpledialog">SimpleDialog</h3>
<p><code>SimpleDialog</code>&#x4E5F;&#x662F;Material&#x7EC4;&#x4EF6;&#x5E93;&#x63D0;&#x4F9B;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#xFF0C;&#x5B83;&#x4F1A;&#x5C55;&#x793A;&#x4E00;&#x4E2A;&#x5217;&#x8868;&#xFF0C;&#x7528;&#x4E8E;&#x5217;&#x8868;&#x9009;&#x62E9;&#x7684;&#x573A;&#x666F;&#x3002;&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x9009;&#x62E9;APP&#x8BED;&#x8A00;&#x7684;&#x793A;&#x4F8B;&#xFF0C;&#x8FD0;&#x884C;&#x7ED3;&#x679C;&#x5982;&#x56FE;7-11&#x3002;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-11.png" alt="&#x56FE;7-11"></p>
<p>&#x5B9E;&#x73B0;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Future<span class="token operator">&lt;</span><span class="token keyword">void</span><span class="token operator">&gt;</span> <span class="token function">changeLanguage</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
  int i <span class="token operator">=</span> <span class="token keyword">await</span> showDialog<span class="token operator">&lt;</span>int<span class="token operator">&gt;</span><span class="token punctuation">(</span>
      context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
      builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token function">SimpleDialog</span><span class="token punctuation">(</span>
          title<span class="token punctuation">:</span> <span class="token keyword">const</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&apos;&#x8BF7;&#x9009;&#x62E9;&#x8BED;&#x8A00;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
            <span class="token function">SimpleDialogOption</span><span class="token punctuation">(</span>
              onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">// &#x8FD4;&#x56DE;1</span>
                Navigator<span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
              <span class="token punctuation">}</span><span class="token punctuation">,</span>
              child<span class="token punctuation">:</span> <span class="token function">Padding</span><span class="token punctuation">(</span>
                padding<span class="token punctuation">:</span> <span class="token keyword">const</span> EdgeInsets<span class="token punctuation">.</span><span class="token function">symmetric</span><span class="token punctuation">(</span>vertical<span class="token punctuation">:</span> <span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                child<span class="token punctuation">:</span> <span class="token keyword">const</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&apos;&#x4E2D;&#x6587;&#x7B80;&#x4F53;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
              <span class="token punctuation">)</span><span class="token punctuation">,</span>
            <span class="token punctuation">)</span><span class="token punctuation">,</span>
            <span class="token function">SimpleDialogOption</span><span class="token punctuation">(</span>
              onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">// &#x8FD4;&#x56DE;2</span>
                Navigator<span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
              <span class="token punctuation">}</span><span class="token punctuation">,</span>
              child<span class="token punctuation">:</span> <span class="token function">Padding</span><span class="token punctuation">(</span>
                padding<span class="token punctuation">:</span> <span class="token keyword">const</span> EdgeInsets<span class="token punctuation">.</span><span class="token function">symmetric</span><span class="token punctuation">(</span>vertical<span class="token punctuation">:</span> <span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                child<span class="token punctuation">:</span> <span class="token keyword">const</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&apos;&#x7F8E;&#x56FD;&#x82F1;&#x8BED;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
              <span class="token punctuation">)</span><span class="token punctuation">,</span>
            <span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token punctuation">]</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token keyword">if</span> <span class="token punctuation">(</span>i <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x9009;&#x62E9;&#x4E86;&#xFF1A;${i == 1 ? &quot;</span>&#x4E2D;&#x6587;&#x7B80;&#x4F53;<span class="token string">&quot; : &quot;</span>&#x7F8E;&#x56FD;&#x82F1;&#x8BED;<span class="token string">&quot;}&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5217;&#x8868;&#x9879;&#x7EC4;&#x4EF6;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x4E86;<code>SimpleDialogOption</code>&#x7EC4;&#x4EF6;&#x6765;&#x5305;&#x88C5;&#x4E86;&#x4E00;&#x4E0B;&#xFF0C;&#x5B83;&#x76F8;&#x5F53;&#x4E8E;&#x4E00;&#x4E2A;FlatButton&#xFF0C;&#x53EA;&#x4E0D;&#x8FC7;&#x6309;&#x94AE;&#x6587;&#x6848;&#x662F;&#x5DE6;&#x5BF9;&#x9F50;&#x7684;&#xFF0C;&#x5E76;&#x4E14;padding&#x8F83;&#x5C0F;&#x3002;&#x4E0A;&#x9762;&#x793A;&#x4F8B;&#x8FD0;&#x884C;&#x540E;&#xFF0C;&#x7528;&#x6237;&#x9009;&#x62E9;&#x4E00;&#x79CD;&#x8BED;&#x8A00;&#x540E;&#xFF0C;&#x63A7;&#x5236;&#x53F0;&#x5C31;&#x4F1A;&#x6253;&#x5370;&#x51FA;&#x5B83;&#x3002;</p>
<h3 id="dialog">Dialog</h3>
<p>&#x5B9E;&#x9645;&#x4E0A;<code>AlertDialog</code>&#x548C;<code>SimpleDialog</code>&#x90FD;&#x4F7F;&#x7528;&#x4E86;<code>Dialog</code>&#x7C7B;&#x3002;&#x7531;&#x4E8E;<code>AlertDialog</code>&#x548C;<code>SimpleDialog</code>&#x4E2D;&#x4F7F;&#x7528;&#x4E86;<code>IntrinsicWidth</code>&#x6765;&#x5C1D;&#x8BD5;&#x901A;&#x8FC7;&#x5B50;&#x7EC4;&#x4EF6;&#x7684;&#x5B9E;&#x9645;&#x5C3A;&#x5BF8;&#x6765;&#x8C03;&#x6574;&#x81EA;&#x8EAB;&#x5C3A;&#x5BF8;&#xFF0C;&#x8FD9;&#x5C31;&#x5BFC;&#x81F4;&#x4ED6;&#x4EEC;&#x7684;&#x5B50;&#x7EC4;&#x4EF6;&#x4E0D;&#x80FD;&#x662F;&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x6A21;&#x578B;&#x7684;&#x7EC4;&#x4EF6;&#xFF08;&#x5982;<code>ListView</code>&#x3001;<code>GridView</code> &#x3001; <code>CustomScrollView</code>&#x7B49;&#xFF09;&#xFF0C;&#x5982;&#x4E0B;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x8FD0;&#x884C;&#x540E;&#x4F1A;&#x62A5;&#x9519;&#x3002;</p>
<pre class="language-"><code class="lang-dart"><span class="token function">AlertDialog</span><span class="token punctuation">(</span>
  content<span class="token punctuation">:</span> <span class="token function">ListView</span><span class="token punctuation">(</span>
    children<span class="token punctuation">:</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token comment">//&#x7701;&#x7565;</span>
  <span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x5C31;&#x662F;&#x9700;&#x8981;&#x5D4C;&#x5957;&#x4E00;&#x4E2A;<code>ListView</code>&#x5E94;&#x8BE5;&#x600E;&#x4E48;&#x505A;&#xFF1F;&#x8FD9;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;<code>Dialog</code>&#x7C7B;&#xFF0C;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token function">Dialog</span><span class="token punctuation">(</span>
  child<span class="token punctuation">:</span> <span class="token function">ListView</span><span class="token punctuation">(</span>
    children<span class="token punctuation">:</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token comment">//&#x7701;&#x7565;</span>
  <span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x770B;&#x4E00;&#x4E2A;&#x5F39;&#x51FA;&#x4E00;&#x4E2A;&#x6709;30&#x4E2A;&#x5217;&#x8868;&#x9879;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#x793A;&#x4F8B;&#xFF0C;&#x8FD0;&#x884C;&#x6548;&#x679C;&#x5982;&#x56FE;7-12&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-12.png" alt="&#x56FE;7-12"></p>
<p>&#x5B9E;&#x73B0;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Future<span class="token operator">&lt;</span><span class="token keyword">void</span><span class="token operator">&gt;</span> <span class="token function">showListDialog</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
  int index <span class="token operator">=</span> <span class="token keyword">await</span> showDialog<span class="token operator">&lt;</span>int<span class="token operator">&gt;</span><span class="token punctuation">(</span>
    context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
    builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">var</span> child <span class="token operator">=</span> <span class="token function">Column</span><span class="token punctuation">(</span>
        children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
          <span class="token function">ListTile</span><span class="token punctuation">(</span>title<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x8BF7;&#x9009;&#x62E9;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token function">Expanded</span><span class="token punctuation">(</span>
              child<span class="token punctuation">:</span> ListView<span class="token punctuation">.</span><span class="token function">builder</span><span class="token punctuation">(</span>
            itemCount<span class="token punctuation">:</span> <span class="token number">30</span><span class="token punctuation">,</span>
            itemBuilder<span class="token punctuation">:</span> <span class="token punctuation">(</span>BuildContext context<span class="token punctuation">,</span> int index<span class="token punctuation">)</span> <span class="token punctuation">{</span>
              <span class="token keyword">return</span> <span class="token function">ListTile</span><span class="token punctuation">(</span>
                title<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;$index&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                onTap<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span>index<span class="token punctuation">)</span><span class="token punctuation">,</span>
              <span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
        <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token comment">//&#x4F7F;&#x7528;AlertDialog&#x4F1A;&#x62A5;&#x9519;</span>
      <span class="token comment">//return AlertDialog(content: child);</span>
      <span class="token keyword">return</span> <span class="token function">Dialog</span><span class="token punctuation">(</span>child<span class="token punctuation">:</span> child<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">if</span> <span class="token punctuation">(</span>index <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x70B9;&#x51FB;&#x4E86;&#xFF1A;$index&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x73B0;&#x5728;&#xFF0C;&#x6211;&#x4EEC;&#x5DF1;&#x7ECF;&#x4ECB;&#x7ECD;&#x5B8C;&#x4E86;<code>AlertDialog</code>&#x3001;<code>SimpleDialog</code>&#x4EE5;&#x53CA;<code>Dialog</code>&#x3002;&#x4E0A;&#x9762;&#x7684;&#x793A;&#x4F8B;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x8C03;&#x7528;<code>showDialog</code>&#x65F6;&#xFF0C;&#x5728;<code>builder</code>&#x4E2D;&#x90FD;&#x662F;&#x6784;&#x5EFA;&#x4E86;&#x8FD9;&#x4E09;&#x4E2A;&#x5BF9;&#x8BDD;&#x6846;&#x7EC4;&#x4EF6;&#x7684;&#x4E00;&#x79CD;&#xFF0C;&#x53EF;&#x80FD;&#x6709;&#x4E9B;&#x8BFB;&#x8005;&#x4F1A;&#x60EF;&#x6027;&#x7684;&#x4EE5;&#x4E3A;&#x5728;<code>builder</code>&#x4E2D;&#x53EA;&#x80FD;&#x8FD4;&#x56DE;&#x8FD9;&#x4E09;&#x8005;&#x4E4B;&#x4E00;&#xFF0C;&#x5176;&#x5B9E;&#x8FD9;&#x4E0D;&#x662F;&#x5FC5;&#x987B;&#x7684;&#xFF01;&#x5C31;&#x62FF;<code>Dialog</code>&#x7684;&#x793A;&#x4F8B;&#x6765;&#x4E3E;&#x4F8B;&#xFF0C;&#x6211;&#x4EEC;&#x5B8C;&#x5168;&#x53EF;&#x4EE5;&#x7528;&#x4E0B;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x6765;&#x66FF;&#x4EE3;<code>Dialog</code>&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token comment">// return Dialog(child: child) </span>
<span class="token keyword">return</span> <span class="token function">UnconstrainedBox</span><span class="token punctuation">(</span>
  constrainedAxis<span class="token punctuation">:</span> Axis<span class="token punctuation">.</span>vertical<span class="token punctuation">,</span>
  child<span class="token punctuation">:</span> <span class="token function">ConstrainedBox</span><span class="token punctuation">(</span>
    constraints<span class="token punctuation">:</span> <span class="token function">BoxConstraints</span><span class="token punctuation">(</span>maxWidth<span class="token punctuation">:</span> <span class="token number">280</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    child<span class="token punctuation">:</span> <span class="token function">Material</span><span class="token punctuation">(</span>
      child<span class="token punctuation">:</span> child<span class="token punctuation">,</span>
      type<span class="token punctuation">:</span> MaterialType<span class="token punctuation">.</span>card<span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x8FD0;&#x884C;&#x540E;&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x4E00;&#x6837;&#x7684;&#x6548;&#x679C;&#x3002;&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x603B;&#x7ED3;&#x4E00;&#x4E0B;&#xFF1A;<code>AlertDialog</code>&#x3001;<code>SimpleDialog</code>&#x4EE5;&#x53CA;<code>Dialog</code>&#x662F;Material&#x7EC4;&#x4EF6;&#x5E93;&#x63D0;&#x4F9B;&#x7684;&#x4E09;&#x79CD;&#x5BF9;&#x8BDD;&#x6846;&#xFF0C;&#x65E8;&#x5728;&#x5E2E;&#x52A9;&#x5F00;&#x53D1;&#x8005;&#x5FEB;&#x901F;&#x6784;&#x5EFA;&#x51FA;&#x7B26;&#x5408;Material&#x8BBE;&#x8BA1;&#x89C4;&#x8303;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#xFF0C;&#x4F46;&#x8BFB;&#x8005;&#x5B8C;&#x5168;&#x53EF;&#x4EE5;&#x81EA;&#x5B9A;&#x4E49;&#x5BF9;&#x8BDD;&#x6846;&#x6837;&#x5F0F;&#xFF0C;&#x56E0;&#x6B64;&#xFF0C;&#x6211;&#x4EEC;&#x4ECD;&#x7136;&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x5404;&#x79CD;&#x6837;&#x5F0F;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#xFF0C;&#x8FD9;&#x6837;&#x5373;&#x5E26;&#x6765;&#x4E86;&#x6613;&#x7528;&#x6027;&#xFF0C;&#x53C8;&#x6709;&#x5F88;&#x5F3A;&#x7684;&#x6269;&#x5C55;&#x6027;&#x3002;</p>
<h2 id="762-&#x5BF9;&#x8BDD;&#x6846;&#x6253;&#x5F00;&#x52A8;&#x753B;&#x53CA;&#x906E;&#x7F69;">7.6.2 &#x5BF9;&#x8BDD;&#x6846;&#x6253;&#x5F00;&#x52A8;&#x753B;&#x53CA;&#x906E;&#x7F69;</h2>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x628A;&#x5BF9;&#x8BDD;&#x6846;&#x5206;&#x4E3A;&#x5185;&#x90E8;&#x6837;&#x5F0F;&#x548C;&#x5916;&#x90E8;&#x6837;&#x5F0F;&#x4E24;&#x90E8;&#x5206;&#x3002;&#x5185;&#x90E8;&#x6837;&#x5F0F;&#x6307;&#x5BF9;&#x8BDD;&#x6846;&#x4E2D;&#x663E;&#x793A;&#x7684;&#x5177;&#x4F53;&#x5185;&#x5BB9;&#xFF0C;&#x8FD9;&#x90E8;&#x5206;&#x5185;&#x5BB9;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5728;&#x4E0A;&#x9762;&#x4ECB;&#x7ECD;&#x8FC7;&#x4E86;&#xFF1B;&#x5916;&#x90E8;&#x6837;&#x5F0F;&#x5305;&#x542B;&#x5BF9;&#x8BDD;&#x6846;&#x906E;&#x7F69;&#x6837;&#x5F0F;&#x3001;&#x6253;&#x5F00;&#x52A8;&#x753B;&#x7B49;&#xFF0C;&#x672C;&#x8282;&#x4E3B;&#x8981;&#x4ECB;&#x7ECD;&#x5982;&#x4F55;&#x81EA;&#x5B9A;&#x4E49;&#x8FD9;&#x4E9B;&#x5916;&#x90E8;&#x6837;&#x5F0F;&#x3002;</p>
<blockquote>
<p>&#x5173;&#x4E8E;&#x52A8;&#x753B;&#x76F8;&#x5173;&#x5185;&#x5BB9;&#x6211;&#x4EEC;&#x5C06;&#x5728;&#x672C;&#x4E66;&#x540E;&#x9762;&#x7AE0;&#x8282;&#x4ECB;&#x7ECD;&#xFF0C;&#x4E0B;&#x9762;&#x5185;&#x5BB9;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x5148;&#x4E86;&#x89E3;&#x4E00;&#x4E0B;&#xFF08;&#x4E0D;&#x5FC5;&#x6DF1;&#x7A76;&#xFF09;&#xFF0C;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x5728;&#x5B66;&#x4E60;&#x5B8C;&#x52A8;&#x753B;&#x76F8;&#x5173;&#x5185;&#x5BB9;&#x540E;&#x518D;&#x56DE;&#x5934;&#x6765;&#x770B;&#x3002;</p>
</blockquote>
<p>&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x4ECB;&#x7ECD;&#x8FC7;&#x4E86;<code>showDialog</code>&#x65B9;&#x6CD5;&#xFF0C;&#x5B83;&#x662F;Material&#x7EC4;&#x4EF6;&#x5E93;&#x4E2D;&#x63D0;&#x4F9B;&#x7684;&#x4E00;&#x4E2A;&#x6253;&#x5F00;Material&#x98CE;&#x683C;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x65B9;&#x6CD5;&#x3002;&#x90A3;&#x5982;&#x4F55;&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x666E;&#x901A;&#x98CE;&#x683C;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#x5462;&#xFF08;&#x975E;Material&#x98CE;&#x683C;&#xFF09;&#xFF1F; Flutter &#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;<code>showGeneralDialog</code>&#x65B9;&#x6CD5;&#xFF0C;&#x7B7E;&#x540D;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Future<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span> showGeneralDialog<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token metadata symbol">@required</span> BuildContext context<span class="token punctuation">,</span>
  <span class="token metadata symbol">@required</span> RoutePageBuilder pageBuilder<span class="token punctuation">,</span> <span class="token comment">//&#x6784;&#x5EFA;&#x5BF9;&#x8BDD;&#x6846;&#x5185;&#x90E8;UI</span>
  bool barrierDismissible<span class="token punctuation">,</span> <span class="token comment">//&#x70B9;&#x51FB;&#x906E;&#x7F69;&#x662F;&#x5426;&#x5173;&#x95ED;&#x5BF9;&#x8BDD;&#x6846;</span>
  String barrierLabel<span class="token punctuation">,</span> <span class="token comment">// &#x8BED;&#x4E49;&#x5316;&#x6807;&#x7B7E;(&#x7528;&#x4E8E;&#x8BFB;&#x5C4F;&#x8F6F;&#x4EF6;)</span>
  Color barrierColor<span class="token punctuation">,</span> <span class="token comment">// &#x906E;&#x7F69;&#x989C;&#x8272;</span>
  Duration transitionDuration<span class="token punctuation">,</span> <span class="token comment">// &#x5BF9;&#x8BDD;&#x6846;&#x6253;&#x5F00;/&#x5173;&#x95ED;&#x7684;&#x52A8;&#x753B;&#x65F6;&#x957F;</span>
  RouteTransitionsBuilder transitionBuilder<span class="token punctuation">,</span> <span class="token comment">// &#x5BF9;&#x8BDD;&#x6846;&#x6253;&#x5F00;/&#x5173;&#x95ED;&#x7684;&#x52A8;&#x753B;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre>
<p>&#x5B9E;&#x9645;&#x4E0A;&#xFF0C;<code>showDialog</code>&#x65B9;&#x6CD5;&#x6B63;&#x662F;<code>showGeneralDialog</code>&#x7684;&#x4E00;&#x4E2A;&#x5C01;&#x88C5;&#xFF0C;&#x5B9A;&#x5236;&#x4E86;Material&#x98CE;&#x683C;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x906E;&#x7F69;&#x989C;&#x8272;&#x548C;&#x52A8;&#x753B;&#x3002;Material&#x98CE;&#x683C;&#x5BF9;&#x8BDD;&#x6846;&#x6253;&#x5F00;/&#x5173;&#x95ED;&#x52A8;&#x753B;&#x662F;&#x4E00;&#x4E2A;Fade&#xFF08;&#x6E10;&#x9690;&#x6E10;&#x663E;&#xFF09;&#x52A8;&#x753B;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x60F3;&#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x7F29;&#x653E;&#x52A8;&#x753B;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>transitionBuilder</code>&#x6765;&#x81EA;&#x5B9A;&#x4E49;&#x3002;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x81EA;&#x5DF1;&#x5C01;&#x88C5;&#x4E00;&#x4E2A;<code>showCustomDialog</code>&#x65B9;&#x6CD5;&#xFF0C;&#x5B83;&#x5B9A;&#x5236;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#x52A8;&#x753B;&#x4E3A;&#x7F29;&#x653E;&#x52A8;&#x753B;&#xFF0C;&#x5E76;&#x540C;&#x65F6;&#x5236;&#x5B9A;&#x906E;&#x7F69;&#x989C;&#x8272;&#x4E3A;<code>Colors.black87</code>&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Future<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span> showCustomDialog<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token metadata symbol">@required</span> BuildContext context<span class="token punctuation">,</span>
  bool barrierDismissible <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
  WidgetBuilder builder<span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">final</span> ThemeData theme <span class="token operator">=</span> Theme<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> shadowThemeOnly<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> <span class="token function">showGeneralDialog</span><span class="token punctuation">(</span>
    context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
    pageBuilder<span class="token punctuation">:</span> <span class="token punctuation">(</span>BuildContext buildContext<span class="token punctuation">,</span> Animation<span class="token operator">&lt;</span>double<span class="token operator">&gt;</span> animation<span class="token punctuation">,</span>
        Animation<span class="token operator">&lt;</span>double<span class="token operator">&gt;</span> secondaryAnimation<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">final</span> Widget pageChild <span class="token operator">=</span> <span class="token function">Builder</span><span class="token punctuation">(</span>builder<span class="token punctuation">:</span> builder<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token keyword">return</span> <span class="token function">SafeArea</span><span class="token punctuation">(</span>
        child<span class="token punctuation">:</span> <span class="token function">Builder</span><span class="token punctuation">(</span>builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token keyword">return</span> theme <span class="token operator">!=</span> <span class="token keyword">null</span>
              <span class="token operator">?</span> <span class="token function">Theme</span><span class="token punctuation">(</span>data<span class="token punctuation">:</span> theme<span class="token punctuation">,</span> child<span class="token punctuation">:</span> pageChild<span class="token punctuation">)</span>
              <span class="token punctuation">:</span> pageChild<span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    barrierDismissible<span class="token punctuation">:</span> barrierDismissible<span class="token punctuation">,</span>
    barrierLabel<span class="token punctuation">:</span> MaterialLocalizations<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span>modalBarrierDismissLabel<span class="token punctuation">,</span>
    barrierColor<span class="token punctuation">:</span> Colors<span class="token punctuation">.</span>black87<span class="token punctuation">,</span> <span class="token comment">// &#x81EA;&#x5B9A;&#x4E49;&#x906E;&#x7F69;&#x989C;&#x8272;</span>
    transitionDuration<span class="token punctuation">:</span> <span class="token keyword">const</span> <span class="token function">Duration</span><span class="token punctuation">(</span>milliseconds<span class="token punctuation">:</span> <span class="token number">150</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    transitionBuilder<span class="token punctuation">:</span> _buildMaterialDialogTransitions<span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

Widget <span class="token function">_buildMaterialDialogTransitions</span><span class="token punctuation">(</span>
    BuildContext context<span class="token punctuation">,</span>
    Animation<span class="token operator">&lt;</span>double<span class="token operator">&gt;</span> animation<span class="token punctuation">,</span>
    Animation<span class="token operator">&lt;</span>double<span class="token operator">&gt;</span> secondaryAnimation<span class="token punctuation">,</span>
    Widget child<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token comment">// &#x4F7F;&#x7528;&#x7F29;&#x653E;&#x52A8;&#x753B;</span>
  <span class="token keyword">return</span> <span class="token function">ScaleTransition</span><span class="token punctuation">(</span>
    scale<span class="token punctuation">:</span> <span class="token function">CurvedAnimation</span><span class="token punctuation">(</span>
      parent<span class="token punctuation">:</span> animation<span class="token punctuation">,</span>
      curve<span class="token punctuation">:</span> Curves<span class="token punctuation">.</span>easeOut<span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
    child<span class="token punctuation">:</span> child<span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x73B0;&#x5728;&#xFF0C;&#x6211;&#x4EEC;&#x4F7F;&#x7528;<code>showCustomDialog</code>&#x6253;&#x5F00;&#x6587;&#x4EF6;&#x5220;&#x9664;&#x786E;&#x8BA4;&#x5BF9;&#x8BDD;&#x6846;&#xFF0C;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
showCustomDialog<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span><span class="token punctuation">(</span>
  context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
  builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token function">AlertDialog</span><span class="token punctuation">(</span>
      title<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x63D0;&#x793A;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      content<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x60A8;&#x786E;&#x5B9A;&#x8981;&#x5220;&#x9664;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x5417;?&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      actions<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
        <span class="token function">FlatButton</span><span class="token punctuation">(</span>
          child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x53D6;&#x6D88;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">,</span>
        <span class="token function">FlatButton</span><span class="token punctuation">(</span>
          child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5220;&#x9664;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">// &#x6267;&#x884C;&#x5220;&#x9664;&#x64CD;&#x4F5C;</span>
            Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">,</span>
      <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x8FD0;&#x884C;&#x6548;&#x679C;&#x5982;&#x56FE;7-13&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-13.png" alt="&#x56FE;7-13"></p>
<p>&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#xFF0C;&#x906E;&#x7F69;&#x989C;&#x8272;&#x6BD4;&#x901A;&#x8FC7;<code>showDialog</code>&#x65B9;&#x6CD5;&#x6253;&#x5F00;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#x66F4;&#x6DF1;&#x3002;&#x53E6;&#x5916;&#x5BF9;&#x8BDD;&#x6846;&#x6253;&#x5F00;/&#x5173;&#x95ED;&#x7684;&#x52A8;&#x753B;&#x5DF2;&#x53D8;&#x4E3A;&#x7F29;&#x653E;&#x52A8;&#x753B;&#x4E86;&#xFF0C;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x4EB2;&#x81EA;&#x8FD0;&#x884C;&#x793A;&#x4F8B;&#x67E5;&#x770B;&#x6548;&#x679C;&#x3002;</p>
<h2 id="763-&#x5BF9;&#x8BDD;&#x6846;&#x5B9E;&#x73B0;&#x539F;&#x7406;">7.6.3 &#x5BF9;&#x8BDD;&#x6846;&#x5B9E;&#x73B0;&#x539F;&#x7406;</h2>
<p>&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x77E5;&#x9053;&#x5BF9;&#x8BDD;&#x6846;&#x6700;&#x7EC8;&#x90FD;&#x662F;&#x7531;<code>showGeneralDialog</code>&#x65B9;&#x6CD5;&#x6253;&#x5F00;&#x7684;&#xFF0C;&#x6211;&#x4EEC;&#x6765;&#x770B;&#x770B;&#x5B83;&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Future<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span> showGeneralDialog<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token metadata symbol">@required</span> BuildContext context<span class="token punctuation">,</span>
  <span class="token metadata symbol">@required</span> RoutePageBuilder pageBuilder<span class="token punctuation">,</span>
  bool barrierDismissible<span class="token punctuation">,</span>
  String barrierLabel<span class="token punctuation">,</span>
  Color barrierColor<span class="token punctuation">,</span>
  Duration transitionDuration<span class="token punctuation">,</span>
  RouteTransitionsBuilder transitionBuilder<span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> rootNavigator<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">.</span>push<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token punctuation">(</span>_DialogRoute<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token punctuation">(</span>
    pageBuilder<span class="token punctuation">:</span> pageBuilder<span class="token punctuation">,</span>
    barrierDismissible<span class="token punctuation">:</span> barrierDismissible<span class="token punctuation">,</span>
    barrierLabel<span class="token punctuation">:</span> barrierLabel<span class="token punctuation">,</span>
    barrierColor<span class="token punctuation">:</span> barrierColor<span class="token punctuation">,</span>
    transitionDuration<span class="token punctuation">:</span> transitionDuration<span class="token punctuation">,</span>
    transitionBuilder<span class="token punctuation">:</span> transitionBuilder<span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x5B9E;&#x73B0;&#x5F88;&#x7B80;&#x5355;&#xFF0C;&#x76F4;&#x63A5;&#x8C03;&#x7528;<code>Navigator</code>&#x7684;<code>push</code>&#x65B9;&#x6CD5;&#x6253;&#x5F00;&#x4E86;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#x8DEF;&#x7531;<code>_DialogRoute</code>&#xFF0C;&#x7136;&#x540E;&#x8FD4;&#x56DE;&#x4E86;<code>push</code>&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x3002;&#x53EF;&#x89C1;&#x5BF9;&#x8BDD;&#x6846;&#x5B9E;&#x9645;&#x4E0A;&#x6B63;&#x662F;&#x901A;&#x8FC7;&#x8DEF;&#x7531;&#x7684;&#x5F62;&#x5F0F;&#x5B9E;&#x73B0;&#x7684;&#xFF0C;&#x8FD9;&#x4E5F;&#x662F;&#x4E3A;&#x4EC0;&#x4E48;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>Navigator</code>&#x7684;<code>pop</code> &#x65B9;&#x6CD5;&#x6765;&#x9000;&#x51FA;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x539F;&#x56E0;&#x3002;&#x5173;&#x4E8E;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x6837;&#x5F0F;&#x5B9A;&#x5236;&#x5728;<code>_DialogRoute</code>&#x4E2D;&#xFF0C;&#x6CA1;&#x6709;&#x4EC0;&#x4E48;&#x65B0;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x81EA;&#x884C;&#x67E5;&#x770B;&#x3002;</p>
<h2 id="764-&#x5BF9;&#x8BDD;&#x6846;&#x72B6;&#x6001;&#x7BA1;&#x7406;">7.6.4 &#x5BF9;&#x8BDD;&#x6846;&#x72B6;&#x6001;&#x7BA1;&#x7406;</h2>
<p>&#x6211;&#x4EEC;&#x5728;&#x7528;&#x6237;&#x9009;&#x62E9;&#x5220;&#x9664;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x65F6;&#xFF0C;&#x4F1A;&#x8BE2;&#x95EE;&#x662F;&#x5426;&#x5220;&#x9664;&#x6B64;&#x6587;&#x4EF6;&#xFF1B;&#x5728;&#x7528;&#x6237;&#x9009;&#x62E9;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x662F;&#xFF0C;&#x5E94;&#x8BE5;&#x518D;&#x8BA9;&#x7528;&#x6237;&#x786E;&#x8BA4;&#x662F;&#x5426;&#x5220;&#x9664;&#x5B50;&#x6587;&#x4EF6;&#x5939;&#x3002;&#x4E3A;&#x4E86;&#x5728;&#x7528;&#x6237;&#x9009;&#x62E9;&#x4E86;&#x6587;&#x4EF6;&#x5939;&#x65F6;&#x907F;&#x514D;&#x4E8C;&#x6B21;&#x5F39;&#x7A97;&#x786E;&#x8BA4;&#x662F;&#x5426;&#x5220;&#x9664;&#x5B50;&#x76EE;&#x5F55;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x786E;&#x8BA4;&#x5BF9;&#x8BDD;&#x6846;&#x5E95;&#x90E8;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x201C;&#x540C;&#x65F6;&#x5220;&#x9664;&#x5B50;&#x76EE;&#x5F55;&#xFF1F;&#x201D;&#x7684;&#x590D;&#x9009;&#x6846;&#xFF0C;&#x5982;&#x56FE;7-14&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-14.png" alt="&#x56FE;7-14"></p>
<p>&#x73B0;&#x5728;&#x5C31;&#x6709;&#x4E00;&#x4E2A;&#x95EE;&#x9898;&#xFF1A;&#x5982;&#x4F55;&#x7BA1;&#x7406;&#x590D;&#x9009;&#x6846;&#x7684;&#x9009;&#x4E2D;&#x72B6;&#x6001;&#xFF1F;&#x4E60;&#x60EF;&#x4E0A;&#xFF0C;&#x6211;&#x4EEC;&#x4F1A;&#x5728;&#x8DEF;&#x7531;&#x9875;&#x7684;State&#x4E2D;&#x6765;&#x7BA1;&#x7406;&#x9009;&#x4E2D;&#x72B6;&#x6001;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x80FD;&#x4F1A;&#x5199;&#x51FA;&#x5982;&#x4E0B;&#x8FD9;&#x6837;&#x7684;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">class</span> <span class="token class-name">_DialogRouteState</span> <span class="token keyword">extends</span> <span class="token class-name">State</span><span class="token operator">&lt;</span>DialogRoute<span class="token operator">&gt;</span> <span class="token punctuation">{</span>
  bool withTree <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span> <span class="token comment">// &#x590D;&#x9009;&#x6846;&#x9009;&#x4E2D;&#x72B6;&#x6001;</span>

  <span class="token metadata symbol">@override</span>
  Widget <span class="token function">build</span><span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token function">Column</span><span class="token punctuation">(</span>
      children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
        <span class="token function">RaisedButton</span><span class="token punctuation">(</span>
          child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5BF9;&#x8BDD;&#x6846;2&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
            bool delete <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">showDeleteConfirmDialog2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>delete <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
              <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x53D6;&#x6D88;&#x5220;&#x9664;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
              <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x540C;&#x65F6;&#x5220;&#x9664;&#x5B50;&#x76EE;&#x5F55;: $delete&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">,</span>
      <span class="token punctuation">]</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  Future<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span> <span class="token function">showDeleteConfirmDialog2</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    withTree <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span> <span class="token comment">// &#x9ED8;&#x8BA4;&#x590D;&#x9009;&#x6846;&#x4E0D;&#x9009;&#x4E2D;</span>
    <span class="token keyword">return</span> showDialog<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span><span class="token punctuation">(</span>
      context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
      builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token function">AlertDialog</span><span class="token punctuation">(</span>
          title<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x63D0;&#x793A;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          content<span class="token punctuation">:</span> <span class="token function">Column</span><span class="token punctuation">(</span>
            crossAxisAlignment<span class="token punctuation">:</span> CrossAxisAlignment<span class="token punctuation">.</span>start<span class="token punctuation">,</span>
            mainAxisSize<span class="token punctuation">:</span> MainAxisSize<span class="token punctuation">.</span>min<span class="token punctuation">,</span>
            children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
              <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x60A8;&#x786E;&#x5B9A;&#x8981;&#x5220;&#x9664;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x5417;?&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
              <span class="token function">Row</span><span class="token punctuation">(</span>
                children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
                  <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x540C;&#x65F6;&#x5220;&#x9664;&#x5B50;&#x76EE;&#x5F55;&#xFF1F;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                  <span class="token function">Checkbox</span><span class="token punctuation">(</span>
                    value<span class="token punctuation">:</span> withTree<span class="token punctuation">,</span>
                    onChanged<span class="token punctuation">:</span> <span class="token punctuation">(</span>bool value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                      <span class="token comment">//&#x590D;&#x9009;&#x6846;&#x9009;&#x4E2D;&#x72B6;&#x6001;&#x53D1;&#x751F;&#x53D8;&#x5316;&#x65F6;&#x91CD;&#x65B0;&#x6784;&#x5EFA;UI</span>
                      <span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                        <span class="token comment">//&#x66F4;&#x65B0;&#x590D;&#x9009;&#x6846;&#x72B6;&#x6001;</span>
                        withTree <span class="token operator">=</span> <span class="token operator">!</span>withTree<span class="token punctuation">;</span>
                      <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token punctuation">}</span><span class="token punctuation">,</span>
                  <span class="token punctuation">)</span><span class="token punctuation">,</span>
                <span class="token punctuation">]</span><span class="token punctuation">,</span>
              <span class="token punctuation">)</span><span class="token punctuation">,</span>
            <span class="token punctuation">]</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span><span class="token punctuation">,</span>
          actions<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
            <span class="token function">FlatButton</span><span class="token punctuation">(</span>
              child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x53D6;&#x6D88;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
              onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            <span class="token punctuation">)</span><span class="token punctuation">,</span>
            <span class="token function">FlatButton</span><span class="token punctuation">(</span>
              child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5220;&#x9664;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
              onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">//&#x6267;&#x884C;&#x5220;&#x9664;&#x64CD;&#x4F5C;</span>
                Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span>withTree<span class="token punctuation">)</span><span class="token punctuation">;</span>
              <span class="token punctuation">}</span><span class="token punctuation">,</span>
            <span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token punctuation">]</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x7136;&#x540E;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x8FD0;&#x884C;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x65F6;&#x6211;&#x4EEC;&#x4F1A;&#x53D1;&#x73B0;&#x590D;&#x9009;&#x6846;&#x6839;&#x672C;&#x9009;&#x4E0D;&#x4E2D;&#xFF01;&#x4E3A;&#x4EC0;&#x4E48;&#x4F1A;&#x8FD9;&#x6837;&#x5462;&#xFF1F;&#x5176;&#x5B9E;&#x539F;&#x56E0;&#x5F88;&#x7B80;&#x5355;&#xFF0C;&#x6211;&#x4EEC;&#x77E5;&#x9053;<code>setState</code>&#x65B9;&#x6CD5;&#x53EA;&#x4F1A;&#x9488;&#x5BF9;&#x5F53;&#x524D;context&#x7684;&#x5B50;&#x6811;&#x91CD;&#x65B0;build&#xFF0C;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x7684;&#x5BF9;&#x8BDD;&#x6846;&#x5E76;&#x4E0D;&#x662F;&#x5728;<code>_DialogRouteState</code>&#x7684;<code>build</code> &#x65B9;&#x6CD5;&#x4E2D;&#x6784;&#x5EFA;&#x7684;&#xFF0C;&#x800C;&#x662F;&#x901A;&#x8FC7;<code>showDialog</code>&#x5355;&#x72EC;&#x6784;&#x5EFA;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x8C03;&#x7528;&#x5728;<code>_DialogRouteState</code>&#x7684;context&#x4E2D;&#x8C03;&#x7528;<code>setState</code>&#x662F;&#x65E0;&#x6CD5;&#x5F71;&#x54CD;&#x901A;&#x8FC7;<code>showDialog</code>&#x6784;&#x5EFA;&#x7684;UI&#x7684;&#x3002;&#x53E6;&#x5916;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4ECE;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x89D2;&#x5EA6;&#x6765;&#x7406;&#x89E3;&#x8FD9;&#x4E2A;&#x73B0;&#x8C61;&#xFF0C;&#x524D;&#x9762;&#x8BF4;&#x8FC7;&#x5BF9;&#x8BDD;&#x6846;&#x4E5F;&#x662F;&#x901A;&#x8FC7;&#x8DEF;&#x7531;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x5B9E;&#x73B0;&#x7684;&#xFF0C;&#x90A3;&#x4E48;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x5B9E;&#x9645;&#x4E0A;&#x5C31;&#x7B49;&#x540C;&#x4E8E;&#x4F01;&#x56FE;&#x5728;&#x7236;&#x8DEF;&#x7531;&#x4E2D;&#x8C03;&#x7528;<code>setState</code>&#x6765;&#x8BA9;&#x5B50;&#x8DEF;&#x7531;&#x66F4;&#x65B0;&#xFF0C;&#x8FD9;&#x663E;&#x7136;&#x662F;&#x4E0D;&#x884C;&#x7684;&#xFF01;&#x7B80;&#x5C14;&#x8A00;&#x4E4B;&#xFF0C;&#x6839;&#x672C;&#x539F;&#x56E0;&#x5C31;&#x662F;context&#x4E0D;&#x5BF9;&#x3002;&#x90A3;&#x5982;&#x4F55;&#x8BA9;&#x590D;&#x9009;&#x6846;&#x53EF;&#x70B9;&#x51FB;&#x5462;&#xFF1F;&#x901A;&#x5E38;&#x6709;&#x5982;&#x4E0B;&#x4E09;&#x79CD;&#x65B9;&#x6CD5;&#xFF1A;</p>
<h3 id="&#x5355;&#x72EC;&#x62BD;&#x79BB;&#x51FA;statefulwidget">&#x5355;&#x72EC;&#x62BD;&#x79BB;&#x51FA;StatefulWidget</h3>
<p>&#x65E2;&#x7136;&#x662F;context&#x4E0D;&#x5BF9;&#xFF0C;&#x90A3;&#x4E48;&#x76F4;&#x63A5;&#x7684;&#x601D;&#x8DEF;&#x5C31;&#x662F;&#x5C06;&#x590D;&#x9009;&#x6846;&#x7684;&#x9009;&#x4E2D;&#x903B;&#x8F91;&#x5355;&#x72EC;&#x5C01;&#x88C5;&#x6210;&#x4E00;&#x4E2A;<code>StatefulWidget</code>&#xFF0C;&#x7136;&#x540E;&#x5728;&#x5176;&#x5185;&#x90E8;&#x7BA1;&#x7406;&#x590D;&#x9009;&#x72B6;&#x6001;&#x3002;&#x6211;&#x4EEC;&#x5148;&#x6765;&#x770B;&#x770B;&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#xFF0C;&#x4E0B;&#x9762;&#x662F;&#x5B9E;&#x73B0;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token comment">// &#x5355;&#x72EC;&#x5C01;&#x88C5;&#x4E00;&#x4E2A;&#x5185;&#x90E8;&#x7BA1;&#x7406;&#x9009;&#x4E2D;&#x72B6;&#x6001;&#x7684;&#x590D;&#x9009;&#x6846;&#x7EC4;&#x4EF6;</span>
<span class="token keyword">class</span> <span class="token class-name">DialogCheckbox</span> <span class="token keyword">extends</span> <span class="token class-name">StatefulWidget</span> <span class="token punctuation">{</span>
  <span class="token function">DialogCheckbox</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    Key key<span class="token punctuation">,</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span>value<span class="token punctuation">,</span>
    <span class="token metadata symbol">@required</span> <span class="token keyword">this</span><span class="token punctuation">.</span>onChanged<span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token keyword">final</span> ValueChanged<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span> onChanged<span class="token punctuation">;</span>
  <span class="token keyword">final</span> bool value<span class="token punctuation">;</span>

  <span class="token metadata symbol">@override</span>
  _DialogCheckboxState <span class="token function">createState</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token function">_DialogCheckboxState</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">_DialogCheckboxState</span> <span class="token keyword">extends</span> <span class="token class-name">State</span><span class="token operator">&lt;</span>DialogCheckbox<span class="token operator">&gt;</span> <span class="token punctuation">{</span>
  bool value<span class="token punctuation">;</span>

  <span class="token metadata symbol">@override</span>
  <span class="token keyword">void</span> <span class="token function">initState</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    value <span class="token operator">=</span> widget<span class="token punctuation">.</span>value<span class="token punctuation">;</span>
    <span class="token keyword">super</span><span class="token punctuation">.</span><span class="token function">initState</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>

  <span class="token metadata symbol">@override</span>
  Widget <span class="token function">build</span><span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token function">Checkbox</span><span class="token punctuation">(</span>
      value<span class="token punctuation">:</span> value<span class="token punctuation">,</span>
      onChanged<span class="token punctuation">:</span> <span class="token punctuation">(</span>v<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">//&#x5C06;&#x9009;&#x4E2D;&#x72B6;&#x6001;&#x901A;&#x8FC7;&#x4E8B;&#x4EF6;&#x7684;&#x5F62;&#x5F0F;&#x629B;&#x51FA;</span>
        widget<span class="token punctuation">.</span><span class="token function">onChanged</span><span class="token punctuation">(</span>v<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token comment">//&#x66F4;&#x65B0;&#x81EA;&#x8EAB;&#x9009;&#x4E2D;&#x72B6;&#x6001;</span>
          value <span class="token operator">=</span> v<span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4E0B;&#x9762;&#x662F;&#x5F39;&#x51FA;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Future<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span> <span class="token function">showDeleteConfirmDialog3</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  bool _withTree <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span> <span class="token comment">//&#x8BB0;&#x5F55;&#x590D;&#x9009;&#x6846;&#x662F;&#x5426;&#x9009;&#x4E2D;</span>
  <span class="token keyword">return</span> showDialog<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span><span class="token punctuation">(</span>
    context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
    builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token function">AlertDialog</span><span class="token punctuation">(</span>
        title<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x63D0;&#x793A;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
        content<span class="token punctuation">:</span> <span class="token function">Column</span><span class="token punctuation">(</span>
          crossAxisAlignment<span class="token punctuation">:</span> CrossAxisAlignment<span class="token punctuation">.</span>start<span class="token punctuation">,</span>
          mainAxisSize<span class="token punctuation">:</span> MainAxisSize<span class="token punctuation">.</span>min<span class="token punctuation">,</span>
          children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
            <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x60A8;&#x786E;&#x5B9A;&#x8981;&#x5220;&#x9664;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x5417;?&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            <span class="token function">Row</span><span class="token punctuation">(</span>
              children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
                <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x540C;&#x65F6;&#x5220;&#x9664;&#x5B50;&#x76EE;&#x5F55;&#xFF1F;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                <span class="token function">DialogCheckbox</span><span class="token punctuation">(</span>
                  value<span class="token punctuation">:</span> _withTree<span class="token punctuation">,</span> <span class="token comment">//&#x9ED8;&#x8BA4;&#x4E0D;&#x9009;&#x4E2D;</span>
                  onChanged<span class="token punctuation">:</span> <span class="token punctuation">(</span>bool value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token comment">//&#x66F4;&#x65B0;&#x9009;&#x4E2D;&#x72B6;&#x6001;</span>
                    _withTree <span class="token operator">=</span> <span class="token operator">!</span>_withTree<span class="token punctuation">;</span>
                  <span class="token punctuation">}</span><span class="token punctuation">,</span>
                <span class="token punctuation">)</span><span class="token punctuation">,</span>
              <span class="token punctuation">]</span><span class="token punctuation">,</span>
            <span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token punctuation">]</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">,</span>
        actions<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
          <span class="token function">FlatButton</span><span class="token punctuation">(</span>
            child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x53D6;&#x6D88;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token function">FlatButton</span><span class="token punctuation">(</span>
            child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5220;&#x9664;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
              <span class="token comment">// &#x5C06;&#x9009;&#x4E2D;&#x72B6;&#x6001;&#x8FD4;&#x56DE;</span>
              Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span>_withTree<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span><span class="token punctuation">,</span>
        <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6700;&#x540E;&#xFF0C;&#x5C31;&#x662F;&#x4F7F;&#x7528;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token function">RaisedButton</span><span class="token punctuation">(</span>
  child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x8BDD;&#x6846;3&#xFF08;&#x590D;&#x9009;&#x6846;&#x53EF;&#x70B9;&#x51FB;&#xFF09;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
    <span class="token comment">//&#x5F39;&#x51FA;&#x5220;&#x9664;&#x786E;&#x8BA4;&#x5BF9;&#x8BDD;&#x6846;&#xFF0C;&#x7B49;&#x5F85;&#x7528;&#x6237;&#x786E;&#x8BA4;</span>
    bool deleteTree <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">showDeleteConfirmDialog3</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>deleteTree <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x53D6;&#x6D88;&#x5220;&#x9664;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
      <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;&#x540C;&#x65F6;&#x5220;&#x9664;&#x5B50;&#x76EE;&#x5F55;: $deleteTree&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre>
<p>&#x8FD0;&#x884C;&#x540E;&#x6548;&#x679C;&#x5982;&#x56FE;7-15&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-15.png" alt="&#x56FE;7-15"></p>
<p>&#x53EF;&#x89C1;&#x590D;&#x9009;&#x6846;&#x80FD;&#x9009;&#x4E2D;&#x4E86;&#xFF0C;&#x70B9;&#x51FB;&#x201C;&#x53D6;&#x6D88;&#x201D;&#x6216;&#x201C;&#x5220;&#x9664;&#x201D;&#x540E;&#xFF0C;&#x63A7;&#x5236;&#x53F0;&#x5C31;&#x4F1A;&#x6253;&#x5370;&#x51FA;&#x6700;&#x7EC8;&#x7684;&#x786E;&#x8BA4;&#x72B6;&#x6001;&#x3002;</p>
<h3 id="&#x4F7F;&#x7528;statefulbuilder&#x65B9;&#x6CD5;">&#x4F7F;&#x7528;StatefulBuilder&#x65B9;&#x6CD5;</h3>
<p>&#x4E0A;&#x9762;&#x7684;&#x65B9;&#x6CD5;&#x867D;&#x7136;&#x80FD;&#x89E3;&#x51B3;&#x5BF9;&#x8BDD;&#x6846;&#x72B6;&#x6001;&#x66F4;&#x65B0;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x4F46;&#x662F;&#x6709;&#x4E00;&#x4E2A;&#x660E;&#x663E;&#x7684;&#x7F3A;&#x70B9;&#x2014;&#x2014;&#x5BF9;&#x8BDD;&#x6846;&#x4E0A;&#x6240;&#x6709;&#x9700;&#x8981;&#x4F1A;&#x6539;&#x53D8;&#x72B6;&#x6001;&#x7684;&#x7EC4;&#x4EF6;&#x90FD;&#x5F97;&#x5355;&#x72EC;&#x5C01;&#x88C5;&#x5728;&#x4E00;&#x4E2A;&#x5728;&#x5185;&#x90E8;&#x7BA1;&#x7406;&#x72B6;&#x6001;<code>StatefulWidget</code>&#x4E2D;&#xFF0C;&#x8FD9;&#x6837;&#x4E0D;&#x4EC5;&#x9EBB;&#x70E6;&#xFF0C;&#x800C;&#x4E14;&#x590D;&#x7528;&#x6027;&#x4E0D;&#x5927;&#x3002;&#x56E0;&#x6B64;&#xFF0C;&#x6211;&#x4EEC;&#x6765;&#x60F3;&#x60F3;&#x80FD;&#x4E0D;&#x80FD;&#x627E;&#x5230;&#x4E00;&#x79CD;&#x66F4;&#x7B80;&#x5355;&#x7684;&#x65B9;&#x6CD5;&#xFF1F;&#x4E0A;&#x9762;&#x7684;&#x65B9;&#x6CD5;&#x672C;&#x8D28;&#x4E0A;&#x5C31;&#x662F;&#x5C06;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x72B6;&#x6001;&#x7F6E;&#x4E8E;&#x4E00;&#x4E2A;<code>StatefulWidget</code>&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#xFF0C;&#x7531;<code>StatefulWidget</code>&#x5728;&#x5185;&#x90E8;&#x7BA1;&#x7406;&#xFF0C;&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x6709;&#x6CA1;&#x6709;&#x529E;&#x6CD5;&#x5728;&#x4E0D;&#x9700;&#x8981;&#x5355;&#x72EC;&#x62BD;&#x79BB;&#x7EC4;&#x4EF6;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>StatefulWidget</code>&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x5462;&#xFF1F;&#x60F3;&#x5230;&#x8FD9;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4ECE;<code>Builder</code>&#x7EC4;&#x4EF6;&#x7684;&#x5B9E;&#x73B0;&#x83B7;&#x5F97;&#x7075;&#x611F;&#x3002;&#x5728;&#x524D;&#x9762;&#x4ECB;&#x7ECD;&#x8FC7;<code>Builder</code>&#x7EC4;&#x4EF6;&#x53EF;&#x4EE5;&#x83B7;&#x5F97;&#x7EC4;&#x4EF6;&#x6240;&#x5728;&#x4F4D;&#x7F6E;&#x7684;&#x771F;&#x6B63;&#x7684;Context&#xFF0C;&#x90A3;&#x5B83;&#x662F;&#x600E;&#x4E48;&#x5B9E;&#x73B0;&#x7684;&#x5462;&#xFF0C;&#x6211;&#x4EEC;&#x770B;&#x770B;&#x5B83;&#x7684;&#x6E90;&#x7801;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">class</span> <span class="token class-name">Builder</span> <span class="token keyword">extends</span> <span class="token class-name">StatelessWidget</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> <span class="token function">Builder</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    Key key<span class="token punctuation">,</span>
    <span class="token metadata symbol">@required</span> <span class="token keyword">this</span><span class="token punctuation">.</span>builder<span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">:</span> <span class="token keyword">assert</span><span class="token punctuation">(</span>builder <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
       <span class="token keyword">super</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> key<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">final</span> WidgetBuilder builder<span class="token punctuation">;</span>

  <span class="token metadata symbol">@override</span>
  Widget <span class="token function">build</span><span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token function">builder</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;<code>Builder</code>&#x5B9E;&#x9645;&#x4E0A;&#x53EA;&#x662F;&#x7EE7;&#x627F;&#x4E86;<code>StatelessWidget</code>&#xFF0C;&#x7136;&#x540E;&#x5728;<code>build</code>&#x65B9;&#x6CD5;&#x4E2D;&#x83B7;&#x53D6;&#x5F53;&#x524D;context&#x540E;&#x5C06;&#x6784;&#x5EFA;&#x65B9;&#x6CD5;&#x4EE3;&#x7406;&#x5230;&#x4E86;<code>builder</code>&#x56DE;&#x8C03;&#xFF0C;&#x53EF;&#x89C1;&#xFF0C;<code>Builder</code>&#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x83B7;&#x53D6;&#x4E86;<code>StatelessWidget</code> &#x7684;&#x4E0A;&#x4E0B;&#x6587;&#xFF08;context&#xFF09;&#x3002;&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x80FD;&#x5426;&#x7528;&#x76F8;&#x540C;&#x7684;&#x65B9;&#x6CD5;&#x83B7;&#x53D6;<code>StatefulWidget</code> &#x7684;&#x4E0A;&#x4E0B;&#x6587;&#xFF0C;&#x5E76;&#x4EE3;&#x7406;&#x5176;<code>build</code>&#x65B9;&#x6CD5;&#x5462;&#xFF1F;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x7167;&#x732B;&#x753B;&#x864E;&#xFF0C;&#x6765;&#x5C01;&#x88C5;&#x4E00;&#x4E2A;<code>StatefulBuilder</code>&#x65B9;&#x6CD5;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">class</span> <span class="token class-name">StatefulBuilder</span> <span class="token keyword">extends</span> <span class="token class-name">StatefulWidget</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> <span class="token function">StatefulBuilder</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    Key key<span class="token punctuation">,</span>
    <span class="token metadata symbol">@required</span> <span class="token keyword">this</span><span class="token punctuation">.</span>builder<span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token punctuation">:</span> <span class="token keyword">assert</span><span class="token punctuation">(</span>builder <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
       <span class="token keyword">super</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> key<span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token keyword">final</span> StatefulWidgetBuilder builder<span class="token punctuation">;</span>

  <span class="token metadata symbol">@override</span>
  _StatefulBuilderState <span class="token function">createState</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> <span class="token function">_StatefulBuilderState</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">class</span> <span class="token class-name">_StatefulBuilderState</span> <span class="token keyword">extends</span> <span class="token class-name">State</span><span class="token operator">&lt;</span>StatefulBuilder<span class="token operator">&gt;</span> <span class="token punctuation">{</span>
  <span class="token metadata symbol">@override</span>
  Widget <span class="token function">build</span><span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> widget<span class="token punctuation">.</span><span class="token function">builder</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> setState<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4EE3;&#x7801;&#x5F88;&#x7B80;&#x5355;&#xFF0C;<code>StatefulBuilder</code>&#x83B7;&#x53D6;&#x4E86;<code>StatefulWidget</code>&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#xFF0C;&#x5E76;&#x4EE3;&#x7406;&#x4E86;&#x5176;&#x6784;&#x5EFA;&#x8FC7;&#x7A0B;&#x3002;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>StatefulBuilder</code>&#x6765;&#x91CD;&#x6784;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x4E86;&#xFF08;&#x53D8;&#x52A8;&#x53EA;&#x5728;<code>DialogCheckbox</code>&#x90E8;&#x5206;&#xFF09;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
<span class="token function">Row</span><span class="token punctuation">(</span>
  children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
    <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x540C;&#x65F6;&#x5220;&#x9664;&#x5B50;&#x76EE;&#x5F55;&#xFF1F;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token comment">//&#x4F7F;&#x7528;StatefulBuilder&#x6765;&#x6784;&#x5EFA;StatefulWidget&#x4E0A;&#x4E0B;&#x6587;</span>
    <span class="token function">StatefulBuilder</span><span class="token punctuation">(</span>
      builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>context<span class="token punctuation">,</span> _setState<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token function">Checkbox</span><span class="token punctuation">(</span>
          value<span class="token punctuation">:</span> _withTree<span class="token punctuation">,</span> <span class="token comment">//&#x9ED8;&#x8BA4;&#x4E0D;&#x9009;&#x4E2D;</span>
          onChanged<span class="token punctuation">:</span> <span class="token punctuation">(</span>bool value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">//_setState&#x65B9;&#x6CD5;&#x5B9E;&#x9645;&#x5C31;&#x662F;&#x8BE5;StatefulWidget&#x7684;setState&#x65B9;&#x6CD5;&#xFF0C;</span>
            <span class="token comment">//&#x8C03;&#x7528;&#x540E;builder&#x65B9;&#x6CD5;&#x4F1A;&#x91CD;&#x65B0;&#x88AB;&#x8C03;&#x7528;</span>
            <span class="token function">_setState</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
              <span class="token comment">//&#x66F4;&#x65B0;&#x9009;&#x4E2D;&#x72B6;&#x6001;</span>
              _withTree <span class="token operator">=</span> <span class="token operator">!</span>_withTree<span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre>
<p>&#x5B9E;&#x9645;&#x4E0A;&#xFF0C;&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x672C;&#x8D28;&#x4E0A;&#x5C31;&#x662F;&#x5B50;&#x7EC4;&#x4EF6;&#x901A;&#x77E5;&#x7236;&#x7EC4;&#x4EF6;&#xFF08;StatefulWidget&#xFF09;&#x91CD;&#x65B0;build&#x5B50;&#x7EC4;&#x4EF6;&#x672C;&#x8EAB;&#x6765;&#x5B9E;&#x73B0;UI&#x66F4;&#x65B0;&#x7684;&#xFF0C;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x5BF9;&#x6BD4;&#x4EE3;&#x7801;&#x7406;&#x89E3;&#x3002;&#x5B9E;&#x9645;&#x4E0A;<code>StatefulBuilder</code>&#x6B63;&#x662F;Flutter SDK&#x4E2D;&#x63D0;&#x4F9B;&#x7684;&#x4E00;&#x4E2A;&#x7C7B;&#xFF0C;&#x5B83;&#x548C;<code>Builder</code>&#x7684;&#x539F;&#x7406;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x5728;&#x6B64;&#xFF0C;&#x63D0;&#x9192;&#x8BFB;&#x8005;&#x4E00;&#x5B9A;&#x8981;&#x5C06;<code>StatefulBuilder</code>&#x548C;<code>Builder</code>&#x7406;&#x89E3;&#x900F;&#x5F7B;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x4EEC;&#x5728;Flutter&#x4E2D;&#x662F;&#x975E;&#x5E38;&#x5B9E;&#x7528;&#x7684;&#x3002;</p>
<h3 id="&#x7CBE;&#x5999;&#x7684;&#x89E3;&#x6CD5;">&#x7CBE;&#x5999;&#x7684;&#x89E3;&#x6CD5;</h3>
<p>&#x8981;&#x786E;&#x8BA4;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x5F97;&#x5148;&#x60F3;&#x60F3;UI&#x662F;&#x600E;&#x4E48;&#x66F4;&#x65B0;&#x7684;&#xFF0C;&#x6211;&#x4EEC;&#x77E5;&#x9053;&#x5728;&#x8C03;&#x7528;<code>setState</code>&#x65B9;&#x6CD5;&#x540E;<code>StatefulWidget</code>&#x5C31;&#x4F1A;&#x91CD;&#x65B0;build&#xFF0C;&#x90A3;<code>setState</code>&#x65B9;&#x6CD5;&#x505A;&#x4E86;&#x4EC0;&#x4E48;&#x5462;&#xFF1F;&#x6211;&#x4EEC;&#x80FD;&#x4E0D;&#x80FD;&#x4ECE;&#x4E2D;&#x627E;&#x5230;&#x65B9;&#x6CD5;&#xFF1F;&#x987A;&#x7740;&#x8FD9;&#x4E2A;&#x601D;&#x8DEF;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x5F97;&#x770B;&#x4E00;&#x4E0B;<code>setState</code>&#x7684;&#x6838;&#x5FC3;&#x6E90;&#x7801;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">setState</span><span class="token punctuation">(</span>VoidCallback fn<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
  _element<span class="token punctuation">.</span><span class="token function">markNeedsBuild</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#xFF0C;<code>setState</code>&#x4E2D;&#x8C03;&#x7528;&#x4E86;<code>Element</code>&#x7684;<code>markNeedsBuild()</code>&#x65B9;&#x6CD5;&#xFF0C;&#x6211;&#x4EEC;&#x524D;&#x9762;&#x8BF4;&#x8FC7;&#xFF0C;Flutter&#x662F;&#x4E00;&#x4E2A;&#x54CD;&#x5E94;&#x5F0F;&#x6846;&#x67B6;&#xFF0C;&#x8981;&#x66F4;&#x65B0;UI&#x53EA;&#x9700;&#x6539;&#x53D8;&#x72B6;&#x6001;&#x540E;&#x901A;&#x77E5;&#x6846;&#x67B6;&#x9875;&#x9762;&#x9700;&#x8981;&#x91CD;&#x6784;&#x5373;&#x53EF;&#xFF0C;&#x800C;<code>Element</code>&#x7684;<code>markNeedsBuild()</code>&#x65B9;&#x6CD5;&#x6B63;&#x662F;&#x6765;&#x5B9E;&#x73B0;&#x8FD9;&#x4E2A;&#x529F;&#x80FD;&#x7684;&#xFF01;<code>markNeedsBuild()</code>&#x65B9;&#x6CD5;&#x4F1A;&#x5C06;&#x5F53;&#x524D;&#x7684;<code>Element</code>&#x5BF9;&#x8C61;&#x6807;&#x8BB0;&#x4E3A;&#x201C;dirty&#x201D;&#xFF08;&#x810F;&#x7684;&#xFF09;&#xFF0C;&#x5728;&#x6BCF;&#x4E00;&#x4E2A;Frame&#xFF0C;Flutter&#x90FD;&#x4F1A;&#x91CD;&#x65B0;&#x6784;&#x5EFA;&#x88AB;&#x6807;&#x8BB0;&#x4E3A;&#x201C;dirty&#x201D;<code>Element</code>&#x5BF9;&#x8C61;&#x3002;&#x65E2;&#x7136;&#x5982;&#x6B64;&#xFF0C;&#x6211;&#x4EEC;&#x6709;&#x6CA1;&#x6709;&#x529E;&#x6CD5;&#x83B7;&#x53D6;&#x5230;&#x5BF9;&#x8BDD;&#x6846;&#x5185;&#x90E8;UI&#x7684;<code>Element</code>&#x5BF9;&#x8C61;&#xFF0C;&#x7136;&#x540E;&#x5C06;&#x5176;&#x6807;&#x793A;&#x4E3A;&#x4E3A;&#x201C;dirty&#x201D;&#x5462;&#xFF1F;&#x7B54;&#x6848;&#x662F;&#x80AF;&#x5B9A;&#x7684;&#xFF01;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;Context&#x6765;&#x5F97;&#x5230;<code>Element</code>&#x5BF9;&#x8C61;&#xFF0C;&#x81F3;&#x4E8E;<code>Element</code>&#x4E0E;<code>Context</code>&#x7684;&#x5173;&#x7CFB;&#x6211;&#x4EEC;&#x5C06;&#x4F1A;&#x5728;&#x540E;&#x9762;&#x201C;Flutter&#x6838;&#x5FC3;&#x539F;&#x7406;&#x201D;&#x4E00;&#x7AE0;&#x4E2D;&#x518D;&#x6DF1;&#x5165;&#x4ECB;&#x7ECD;&#xFF0C;&#x73B0;&#x5728;&#x53EA;&#x9700;&#x8981;&#x7B80;&#x5355;&#x7684;&#x8BA4;&#x4E3A;&#xFF1A;&#x5728;&#x7EC4;&#x4EF6;&#x6811;&#x4E2D;&#xFF0C;<code>context</code>&#x5B9E;&#x9645;&#x4E0A;&#x5C31;&#x662F;<code>Element</code>&#x5BF9;&#x8C61;&#x7684;&#x5F15;&#x7528;&#x3002;&#x77E5;&#x9053;&#x8FD9;&#x4E2A;&#x540E;&#xFF0C;&#x90A3;&#x4E48;&#x89E3;&#x51B3;&#x7684;&#x65B9;&#x6848;&#x5C31;&#x547C;&#x4E4B;&#x6B32;&#x51FA;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5982;&#x4E0B;&#x65B9;&#x5F0F;&#x6765;&#x8BA9;&#x590D;&#x9009;&#x6846;&#x53EF;&#x4EE5;&#x66F4;&#x65B0;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Future<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span> <span class="token function">showDeleteConfirmDialog4</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  bool _withTree <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> showDialog<span class="token operator">&lt;</span>bool<span class="token operator">&gt;</span><span class="token punctuation">(</span>
    context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
    builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token function">AlertDialog</span><span class="token punctuation">(</span>
        title<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x63D0;&#x793A;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
        content<span class="token punctuation">:</span> <span class="token function">Column</span><span class="token punctuation">(</span>
          crossAxisAlignment<span class="token punctuation">:</span> CrossAxisAlignment<span class="token punctuation">.</span>start<span class="token punctuation">,</span>
          mainAxisSize<span class="token punctuation">:</span> MainAxisSize<span class="token punctuation">.</span>min<span class="token punctuation">,</span>
          children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
            <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x60A8;&#x786E;&#x5B9A;&#x8981;&#x5220;&#x9664;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x5417;?&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            <span class="token function">Row</span><span class="token punctuation">(</span>
              children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
                <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x540C;&#x65F6;&#x5220;&#x9664;&#x5B50;&#x76EE;&#x5F55;&#xFF1F;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                <span class="token function">Checkbox</span><span class="token punctuation">(</span> <span class="token comment">// &#x4F9D;&#x7136;&#x4F7F;&#x7528;Checkbox&#x7EC4;&#x4EF6;</span>
                  value<span class="token punctuation">:</span> _withTree<span class="token punctuation">,</span>
                  onChanged<span class="token punctuation">:</span> <span class="token punctuation">(</span>bool value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token comment">// &#x6B64;&#x65F6;context&#x4E3A;&#x5BF9;&#x8BDD;&#x6846;UI&#x7684;&#x6839;Element&#xFF0C;&#x6211;&#x4EEC; </span>
                    <span class="token comment">// &#x76F4;&#x63A5;&#x5C06;&#x5BF9;&#x8BDD;&#x6846;UI&#x5BF9;&#x5E94;&#x7684;Element&#x6807;&#x8BB0;&#x4E3A;dirty</span>
                    <span class="token punctuation">(</span>context <span class="token operator">as</span> Element<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">markNeedsBuild</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    _withTree <span class="token operator">=</span> <span class="token operator">!</span>_withTree<span class="token punctuation">;</span>
                  <span class="token punctuation">}</span><span class="token punctuation">,</span>
                <span class="token punctuation">)</span><span class="token punctuation">,</span>
              <span class="token punctuation">]</span><span class="token punctuation">,</span>
            <span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token punctuation">]</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">,</span>
        actions<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
          <span class="token function">FlatButton</span><span class="token punctuation">(</span>
            child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x53D6;&#x6D88;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token function">FlatButton</span><span class="token punctuation">(</span>
            child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5220;&#x9664;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
              <span class="token comment">// &#x6267;&#x884C;&#x5220;&#x9664;&#x64CD;&#x4F5C;</span>
              Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span>_withTree<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span><span class="token punctuation">,</span>
        <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x8FD0;&#x884C;&#x540E;&#x590D;&#x9009;&#x6846;&#x4E5F;&#x53EF;&#x4EE5;&#x6B63;&#x5E38;&#x9009;&#x4E2D;&#x3002;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x6211;&#x4EEC;&#x53EA;&#x7528;&#x4E86;&#x4E00;&#x884C;&#x4EE3;&#x7801;&#x4FBF;&#x89E3;&#x51B3;&#x4E86;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#xFF01;&#x5F53;&#x7136;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x5E76;&#x4E0D;&#x662F;&#x6700;&#x4F18;&#xFF0C;&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x66F4;&#x65B0;&#x590D;&#x9009;&#x6846;&#x7684;&#x72B6;&#x6001;&#xFF0C;&#x800C;&#x6B64;&#x65F6;&#x7684;<code>context</code>&#x6211;&#x4EEC;&#x7528;&#x7684;&#x662F;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x6839;<code>context</code>&#xFF0C;&#x6240;&#x4EE5;&#x4F1A;&#x5BFC;&#x81F4;&#x6574;&#x4E2A;&#x5BF9;&#x8BDD;&#x6846;UI&#x7EC4;&#x4EF6;&#x5168;&#x90E8;rebuild&#xFF0C;&#x56E0;&#x6B64;&#x6700;&#x597D;&#x7684;&#x505A;&#x6CD5;&#x662F;&#x5C06;<code>context</code>&#x7684;&#x201C;&#x8303;&#x56F4;&#x201D;&#x7F29;&#x5C0F;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x53EA;&#x5C06;<code>Checkbox</code>&#x7684;Element&#x6807;&#x8BB0;&#x4E3A;<code>dirty</code>&#xFF0C;&#x4F18;&#x5316;&#x540E;&#x7684;&#x4EE3;&#x7801;&#x4E3A;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
<span class="token function">Row</span><span class="token punctuation">(</span>
  children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
    <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x540C;&#x65F6;&#x5220;&#x9664;&#x5B50;&#x76EE;&#x5F55;&#xFF1F;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token comment">// &#x901A;&#x8FC7;Builder&#x6765;&#x83B7;&#x5F97;&#x6784;&#x5EFA;Checkbox&#x7684;`context`&#xFF0C;</span>
    <span class="token comment">// &#x8FD9;&#x662F;&#x4E00;&#x79CD;&#x5E38;&#x7528;&#x7684;&#x7F29;&#x5C0F;`context`&#x8303;&#x56F4;&#x7684;&#x65B9;&#x5F0F;</span>
    <span class="token function">Builder</span><span class="token punctuation">(</span>
      builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token function">Checkbox</span><span class="token punctuation">(</span>
          value<span class="token punctuation">:</span> _withTree<span class="token punctuation">,</span>
          onChanged<span class="token punctuation">:</span> <span class="token punctuation">(</span>bool value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token punctuation">(</span>context <span class="token operator">as</span> Element<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">markNeedsBuild</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            _withTree <span class="token operator">=</span> <span class="token operator">!</span>_withTree<span class="token punctuation">;</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token punctuation">]</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre>
<h2 id="765-&#x5176;&#x5B83;&#x7C7B;&#x578B;&#x7684;&#x5BF9;&#x8BDD;&#x6846;">7.6.5 &#x5176;&#x5B83;&#x7C7B;&#x578B;&#x7684;&#x5BF9;&#x8BDD;&#x6846;</h2>
<h3 id="&#x5E95;&#x90E8;&#x83DC;&#x5355;&#x5217;&#x8868;">&#x5E95;&#x90E8;&#x83DC;&#x5355;&#x5217;&#x8868;</h3>
<p><code>showModalBottomSheet</code>&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x5F39;&#x51FA;&#x4E00;&#x4E2A;Material&#x98CE;&#x683C;&#x7684;&#x5E95;&#x90E8;&#x83DC;&#x5355;&#x5217;&#x8868;&#x6A21;&#x6001;&#x5BF9;&#x8BDD;&#x6846;&#xFF0C;&#x793A;&#x4F8B;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token comment">// &#x5F39;&#x51FA;&#x5E95;&#x90E8;&#x83DC;&#x5355;&#x5217;&#x8868;&#x6A21;&#x6001;&#x5BF9;&#x8BDD;&#x6846;</span>
Future<span class="token operator">&lt;</span>int<span class="token operator">&gt;</span> <span class="token function">_showModalBottomSheet</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> showModalBottomSheet<span class="token operator">&lt;</span>int<span class="token operator">&gt;</span><span class="token punctuation">(</span>
    context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
    builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> ListView<span class="token punctuation">.</span><span class="token function">builder</span><span class="token punctuation">(</span>
        itemCount<span class="token punctuation">:</span> <span class="token number">30</span><span class="token punctuation">,</span>
        itemBuilder<span class="token punctuation">:</span> <span class="token punctuation">(</span>BuildContext context<span class="token punctuation">,</span> int index<span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token keyword">return</span> <span class="token function">ListTile</span><span class="token punctuation">(</span>
            title<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;$index&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            onTap<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span>index<span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x70B9;&#x51FB;&#x6309;&#x94AE;&#xFF0C;&#x5F39;&#x51FA;&#x8BE5;&#x5BF9;&#x8BDD;&#x6846;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token function">RaisedButton</span><span class="token punctuation">(</span>
  child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x663E;&#x793A;&#x5E95;&#x90E8;&#x83DC;&#x5355;&#x5217;&#x8868;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  onPressed<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
    int type <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">_showModalBottomSheet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">print</span><span class="token punctuation">(</span>type<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre>
<p>&#x8FD0;&#x884C;&#x540E;&#x6548;&#x679C;&#x5982;&#x56FE;7-16&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-16.png" alt="&#x56FE;7-16"></p>
<p><code>showModalBottomSheet</code>&#x7684;&#x5B9E;&#x73B0;&#x539F;&#x7406;&#x548C;<code>showGeneralDialog</code>&#x5B9E;&#x73B0;&#x539F;&#x7406;&#x76F8;&#x540C;&#xFF0C;&#x90FD;&#x662F;&#x901A;&#x8FC7;&#x8DEF;&#x7531;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x5B9E;&#x73B0;&#x7684;&#xFF0C;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x6E90;&#x7801;&#x5BF9;&#x6BD4;&#x3002;&#x4F46;&#x503C;&#x5F97;&#x4E00;&#x63D0;&#x7684;&#x662F;&#x8FD8;&#x6709;&#x4E00;&#x4E2A;<code>showBottomSheet</code>&#x65B9;&#x6CD5;&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x4F1A;&#x4ECE;&#x8BBE;&#x5907;&#x5E95;&#x90E8;&#x5411;&#x4E0A;&#x5F39;&#x51FA;&#x4E00;&#x4E2A;&#x5168;&#x5C4F;&#x7684;&#x83DC;&#x5355;&#x5217;&#x8868;&#xFF0C;&#x793A;&#x4F8B;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token comment">// &#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4E00;&#x4E2A;controller</span>
PersistentBottomSheetController<span class="token operator">&lt;</span>int<span class="token operator">&gt;</span> <span class="token function">_showBottomSheet</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> showBottomSheet<span class="token operator">&lt;</span>int<span class="token operator">&gt;</span><span class="token punctuation">(</span>
    context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
    builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> ListView<span class="token punctuation">.</span><span class="token function">builder</span><span class="token punctuation">(</span>
        itemCount<span class="token punctuation">:</span> <span class="token number">30</span><span class="token punctuation">,</span>
        itemBuilder<span class="token punctuation">:</span> <span class="token punctuation">(</span>BuildContext context<span class="token punctuation">,</span> int index<span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token keyword">return</span> <span class="token function">ListTile</span><span class="token punctuation">(</span>
            title<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;$index&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            onTap<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
              <span class="token comment">// do something</span>
              <span class="token function">print</span><span class="token punctuation">(</span><span class="token string">&quot;$index&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
              Navigator<span class="token punctuation">.</span><span class="token function">of</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8FD0;&#x884C;&#x6548;&#x679C;&#x5982;&#x56FE;7-17&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-17.png" alt="&#x56FE;7-17"></p>
<p><code>PersistentBottomSheetController</code>&#x4E2D;&#x5305;&#x542B;&#x4E86;&#x4E00;&#x4E9B;&#x63A7;&#x5236;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x65B9;&#x6CD5;&#x6BD4;&#x5982;<code>close</code>&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x5173;&#x95ED;&#x8BE5;&#x5BF9;&#x8BDD;&#x6846;&#xFF0C;&#x529F;&#x80FD;&#x6BD4;&#x8F83;&#x7B80;&#x5355;&#xFF0C;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x81EA;&#x884C;&#x67E5;&#x770B;&#x6E90;&#x7801;&#x3002;&#x552F;&#x4E00;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;<code>showBottomSheet</code>&#x548C;&#x6211;&#x4EEC;&#x4E0A;&#x9762;&#x4ECB;&#x7ECD;&#x7684;&#x5F39;&#x51FA;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x65B9;&#x6CD5;&#x539F;&#x7406;&#x4E0D;&#x540C;&#xFF1A;<code>showBottomSheet</code>&#x662F;&#x8C03;&#x7528;widget&#x6811;&#x9876;&#x90E8;&#x7684;<code>Scaffold</code>&#x7EC4;&#x4EF6;&#x7684;<code>ScaffoldState</code>&#x7684;<code>showBottomSheet</code>&#x540C;&#x540D;&#x65B9;&#x6CD5;&#x5B9E;&#x73B0;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x8981;&#x8C03;&#x7528;<code>showBottomSheet</code>&#x65B9;&#x6CD5;&#x5C31;&#x5FC5;&#x987B;&#x5F97;&#x4FDD;&#x8BC1;&#x7236;&#x7EA7;&#x7EC4;&#x4EF6;&#x4E2D;&#x6709;<code>Scaffold</code>&#x3002;</p>
<h3 id="loading&#x6846;">Loading&#x6846;</h3>
<p>&#x5176;&#x5B9E;Loading&#x6846;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x901A;&#x8FC7;<code>showDialog</code>+<code>AlertDialog</code>&#x6765;&#x81EA;&#x5B9A;&#x4E49;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token function">showLoadingDialog</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">showDialog</span><span class="token punctuation">(</span>
    context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
    barrierDismissible<span class="token punctuation">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span> <span class="token comment">//&#x70B9;&#x51FB;&#x906E;&#x7F69;&#x4E0D;&#x5173;&#x95ED;&#x5BF9;&#x8BDD;&#x6846;</span>
    builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token function">AlertDialog</span><span class="token punctuation">(</span>
        content<span class="token punctuation">:</span> <span class="token function">Column</span><span class="token punctuation">(</span>
          mainAxisSize<span class="token punctuation">:</span> MainAxisSize<span class="token punctuation">.</span>min<span class="token punctuation">,</span>
          children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
            <span class="token function">CircularProgressIndicator</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            <span class="token function">Padding</span><span class="token punctuation">(</span>
              padding<span class="token punctuation">:</span> <span class="token keyword">const</span> EdgeInsets<span class="token punctuation">.</span><span class="token function">only</span><span class="token punctuation">(</span>top<span class="token punctuation">:</span> <span class="token number">26.0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
              child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x6B63;&#x5728;&#x52A0;&#x8F7D;&#xFF0C;&#x8BF7;&#x7A0D;&#x540E;...&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            <span class="token punctuation">)</span>
          <span class="token punctuation">]</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x663E;&#x793A;&#x6548;&#x679C;&#x5982;&#x56FE;7-18&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-18.png" alt="&#x56FE;7-18"></p>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x5ACC;Loading&#x6846;&#x592A;&#x5BBD;&#xFF0C;&#x60F3;&#x81EA;&#x5B9A;&#x4E49;&#x5BF9;&#x8BDD;&#x6846;&#x5BBD;&#x5EA6;&#xFF0C;&#x8FD9;&#x65F6;&#x53EA;&#x4F7F;&#x7528;<code>SizedBox</code>&#x6216;<code>ConstrainedBox</code>&#x662F;&#x4E0D;&#x884C;&#x7684;&#xFF0C;&#x539F;&#x56E0;&#x662F;<code>showDialog</code>&#x4E2D;&#x5DF2;&#x7ECF;&#x7ED9;&#x5BF9;&#x8BDD;&#x6846;&#x8BBE;&#x7F6E;&#x4E86;&#x5BBD;&#x5EA6;&#x9650;&#x5236;&#xFF0C;&#x6839;&#x636E;&#x6211;&#x4EEC;&#x5728;&#x7B2C;&#x4E94;&#x7AE0;&#x201C;&#x5C3A;&#x5BF8;&#x9650;&#x5236;&#x7C7B;&#x5BB9;&#x5668;&#x201D;&#x4E00;&#x8282;&#x4E2D;&#x6240;&#x8FF0;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>UnconstrainedBox</code>&#x5148;&#x62B5;&#x6D88;<code>showDialog</code>&#x5BF9;&#x5BBD;&#x5EA6;&#x7684;&#x9650;&#x5236;&#xFF0C;&#x7136;&#x540E;&#x518D;&#x4F7F;&#x7528;<code>SizedBox</code>&#x6307;&#x5B9A;&#x5BBD;&#x5EA6;&#xFF0C;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
<span class="token function">UnconstrainedBox</span><span class="token punctuation">(</span>
  constrainedAxis<span class="token punctuation">:</span> Axis<span class="token punctuation">.</span>vertical<span class="token punctuation">,</span>
  child<span class="token punctuation">:</span> <span class="token function">SizedBox</span><span class="token punctuation">(</span>
    width<span class="token punctuation">:</span> <span class="token number">280</span><span class="token punctuation">,</span>
    child<span class="token punctuation">:</span> <span class="token function">AlertDialog</span><span class="token punctuation">(</span>
      content<span class="token punctuation">:</span> <span class="token function">Column</span><span class="token punctuation">(</span>
        mainAxisSize<span class="token punctuation">:</span> MainAxisSize<span class="token punctuation">.</span>min<span class="token punctuation">,</span>
        children<span class="token punctuation">:</span> <span class="token operator">&lt;</span>Widget<span class="token operator">&gt;</span><span class="token punctuation">[</span>
          <span class="token function">CircularProgressIndicator</span><span class="token punctuation">(</span>value<span class="token punctuation">:</span> <span class="token number">.8</span><span class="token punctuation">,</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token function">Padding</span><span class="token punctuation">(</span>
            padding<span class="token punctuation">:</span> <span class="token keyword">const</span> EdgeInsets<span class="token punctuation">.</span><span class="token function">only</span><span class="token punctuation">(</span>top<span class="token punctuation">:</span> <span class="token number">26.0</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            child<span class="token punctuation">:</span> <span class="token function">Text</span><span class="token punctuation">(</span><span class="token string">&quot;&#x6B63;&#x5728;&#x52A0;&#x8F7D;&#xFF0C;&#x8BF7;&#x7A0D;&#x540E;...&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span>
        <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x4EE3;&#x7801;&#x8FD0;&#x884C;&#x540E;&#xFF0C;&#x6548;&#x679C;&#x5982;&#x56FE;7-19&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-19.png" alt="&#x56FE;7-19"></p>
<h3 id="&#x65E5;&#x5386;&#x9009;&#x62E9;">&#x65E5;&#x5386;&#x9009;&#x62E9;</h3>
<p>&#x6211;&#x4EEC;&#x5148;&#x770B;&#x4E00;&#x4E0B;Material&#x98CE;&#x683C;&#x7684;&#x65E5;&#x5386;&#x9009;&#x62E9;&#x5668;&#xFF0C;&#x5982;&#x56FE;7-20&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-20.png" alt="&#x56FE;7-20"></p>
<p>&#x5B9E;&#x73B0;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Future<span class="token operator">&lt;</span>DateTime<span class="token operator">&gt;</span> <span class="token function">_showDatePicker1</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">var</span> date <span class="token operator">=</span> DateTime<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> <span class="token function">showDatePicker</span><span class="token punctuation">(</span>
    context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
    initialDate<span class="token punctuation">:</span> date<span class="token punctuation">,</span>
    firstDate<span class="token punctuation">:</span> date<span class="token punctuation">,</span>
    lastDate<span class="token punctuation">:</span> date<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span> <span class="token comment">//&#x672A;&#x6765;30&#x5929;&#x53EF;&#x9009;</span>
      <span class="token function">Duration</span><span class="token punctuation">(</span>days<span class="token punctuation">:</span> <span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>iOS&#x98CE;&#x683C;&#x7684;&#x65E5;&#x5386;&#x9009;&#x62E9;&#x5668;&#x9700;&#x8981;&#x4F7F;&#x7528;<code>showCupertinoModalPopup</code>&#x65B9;&#x6CD5;&#x548C;<code>CupertinoDatePicker</code>&#x7EC4;&#x4EF6;&#x6765;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Future<span class="token operator">&lt;</span>DateTime<span class="token operator">&gt;</span> <span class="token function">_showDatePicker2</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">var</span> date <span class="token operator">=</span> DateTime<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> <span class="token function">showCupertinoModalPopup</span><span class="token punctuation">(</span>
    context<span class="token punctuation">:</span> context<span class="token punctuation">,</span>
    builder<span class="token punctuation">:</span> <span class="token punctuation">(</span>ctx<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token function">SizedBox</span><span class="token punctuation">(</span>
        height<span class="token punctuation">:</span> <span class="token number">200</span><span class="token punctuation">,</span>
        child<span class="token punctuation">:</span> <span class="token function">CupertinoDatePicker</span><span class="token punctuation">(</span>
          mode<span class="token punctuation">:</span> CupertinoDatePickerMode<span class="token punctuation">.</span>dateAndTime<span class="token punctuation">,</span>
          minimumDate<span class="token punctuation">:</span> date<span class="token punctuation">,</span>
          maximumDate<span class="token punctuation">:</span> date<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>
            <span class="token function">Duration</span><span class="token punctuation">(</span>days<span class="token punctuation">:</span> <span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          <span class="token punctuation">)</span><span class="token punctuation">,</span>
          maximumYear<span class="token punctuation">:</span> date<span class="token punctuation">.</span>year <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span>
          onDateTimeChanged<span class="token punctuation">:</span> <span class="token punctuation">(</span>DateTime value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token function">print</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">)</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8FD0;&#x884C;&#x6548;&#x679C;&#x5982;&#x56FE;7-21&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/7-21.png" alt="&#x56FE;7-21"></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="futurebuilder_and_streambuilder.html" class="navigation navigation-prev " aria-label="Previous page: 7.5：异步UI更新（FutureBuilder、StreamBuilder）">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../chapter8/" class="navigation navigation-next " aria-label="Next page: 第八章：事件处理与通知">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"7.6：对话框详解","level":"2.7.6","depth":2,"next":{"title":"第八章：事件处理与通知","level":"3.1","depth":1,"path":"chapter8/index.md","ref":"chapter8/index.md","articles":[{"title":"8.1：原始指针事件处理","level":"3.1.1","depth":2,"path":"chapter8/listener.md","ref":"chapter8/listener.md","articles":[]},{"title":"8.2：手势识别","level":"3.1.2","depth":2,"path":"chapter8/gesture.md","ref":"chapter8/gesture.md","articles":[]},{"title":"8.3：全局事件总线","level":"3.1.3","depth":2,"path":"chapter8/eventbus.md","ref":"chapter8/eventbus.md","articles":[]},{"title":"8.4：通知(Notification)","level":"3.1.4","depth":2,"path":"chapter8/notification.md","ref":"chapter8/notification.md","articles":[]}]},"previous":{"title":"7.5：异步UI更新（FutureBuilder、StreamBuilder）","level":"2.7.5","depth":2,"path":"chapter7/futurebuilder_and_streambuilder.md","ref":"chapter7/futurebuilder_and_streambuilder.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-pro","ace","splitter","prism","donate","-highlight"],"root":"docs","styles":{"website":"styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"prism":{"lang":{"shell":"bash"}},"ace":{},"splitter":{},"search-pro":{"cutWordLib":"nodejieba","defineWord":["Gitbook Use"]},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action@1.0.3/docs/imgs/pay.jpeg","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"wendux 824783146@qq.com","bookRoot":"https://book.flutterchina.club/","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《Flutter实战》","language":"zh-hans","links":{"sharing":{"all":null,"facebook":null,"google":null,"twitter":null,"weibo":null},"sidebar":{"<div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div>":"https://flutterchina.club"}},"gitbook":"*","description":"记录Gitbook的配置和一些插件的使用"},"file":{"path":"chapter7/dailog.md","mtime":"2019-10-14T09:37:56.770Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-03-15T14:52:22.710Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>



    <script src="https://pcdn.flutterchina.club/gitbook/gitbook.js"></script>
    <script src="https://pcdn.flutterchina.club/gitbook/theme.js"></script>
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    


<script src="https://pcdn.flutterchina.club/gitbook/pub.js"></script>
<script>
    hookAjax({
        open: function (arg, xhr) {
            if (location.hostname !== 'localhost') {
                if (arg[1][0] === '.') arg[1] = arg[1].slice(1);
                arg[1] = "https://pcdn.flutterchina.club" + arg[1].replace(".html", ".1")
            }
        },
        setRequestHeader: function (arg, xhr) {
            console.log(arg[0], arg[1]);
            if (arg[0] !== 'Accept') return true;
        },
        onload:function(){
            setTimeout(addAD);
        }
    })
</script>
</body>

</html>

